/* ==================== LANDING (portada de elyria.app) ==================== */
#elyria-landing {
  --lp-rose: #d75f92; --lp-rose-deep: #c14e7f; --lp-rose-soft: #fbe1ec;
  --lp-bg: #fff5f9; --lp-ink: #3a2731; --lp-muted: #927882;
  --lp-line: #f3d9e5;
  position: fixed; inset: 0; z-index: 9000; overflow-y: auto;
  background: var(--lp-bg); color: var(--lp-ink);
  font-family: 'Inter', -apple-system, sans-serif; -webkit-font-smoothing: antialiased;
}
#elyria-landing a { color: inherit; text-decoration: none; }

/* Nav */
#elyria-landing .lp-nav {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px;
  padding: 16px 32px; background: rgba(255,245,249,.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--lp-line);
}
#elyria-landing .lp-brand { font-family: 'Lora', Georgia, serif; font-size: 25px; font-weight: 600; color: var(--lp-rose-deep); letter-spacing: .5px; }
#elyria-landing .lp-nav-links { display: flex; gap: 26px; margin-left: 18px; }
#elyria-landing .lp-nav-links a { font-size: 14px; font-weight: 500; color: var(--lp-muted); }
#elyria-landing .lp-nav-links a:hover { color: var(--lp-rose-deep); }
#elyria-landing .lp-nav-actions { display: flex; gap: 10px; margin-left: auto; }

/* Botones */
#elyria-landing .lp-btn {
  border: none; border-radius: 999px; cursor: pointer; font-family: inherit;
  font-size: 14px; font-weight: 600; padding: 10px 20px; transition: background .15s, transform .05s, box-shadow .15s;
}
#elyria-landing .lp-btn:active { transform: translateY(1px); }
#elyria-landing .lp-btn-primary { background: var(--lp-rose); color: #fff; box-shadow: 0 6px 18px rgba(215,95,146,.28); }
#elyria-landing .lp-btn-primary:hover { background: var(--lp-rose-deep); }
#elyria-landing .lp-btn-ghost { background: #fff; color: var(--lp-rose-deep); border: 1px solid var(--lp-line); }
#elyria-landing .lp-btn-ghost:hover { background: var(--lp-rose-soft); }
#elyria-landing .lp-btn-lg { padding: 15px 30px; font-size: 15.5px; }
#elyria-landing .lp-btn-block { display: block; width: 100%; margin-top: 8px; }

/* Hero */
#elyria-landing .lp-hero {
  display: grid; grid-template-columns: 1.05fr 1.25fr; gap: 40px; align-items: center;
  max-width: 1180px; margin: 0 auto; padding: 70px 32px 40px;
  background:
    radial-gradient(900px 480px at 78% 6%, #ffe3ef 0%, rgba(255,227,239,0) 60%),
    radial-gradient(700px 420px at 10% 30%, #fbeaf6 0%, rgba(251,234,246,0) 55%);
}
#elyria-landing .lp-hero-badge {
  display: inline-block; font-size: 12.5px; font-weight: 600; color: var(--lp-rose-deep);
  background: #fff; border: 1px solid var(--lp-line); padding: 6px 14px; border-radius: 999px; margin-bottom: 20px;
}
#elyria-landing .lp-title { font-family: 'Lora', Georgia, serif; font-size: 54px; line-height: 1.08; font-weight: 600; margin: 0 0 18px; color: var(--lp-ink); letter-spacing: -.5px; }
#elyria-landing .lp-sub { font-size: 18px; line-height: 1.6; color: var(--lp-muted); margin: 0 0 28px; max-width: 500px; }
#elyria-landing .lp-cta { display: flex; gap: 12px; flex-wrap: wrap; }
#elyria-landing .lp-cta-note { font-size: 13px; color: #b79aa6; margin-top: 16px; }

/* Marcos de dispositivo (ventana de navegador) */
#elyria-landing .lp-window {
  background: #fff; border: 1px solid var(--lp-line); border-radius: 14px; overflow: hidden;
  box-shadow: 0 30px 70px -30px rgba(150,50,95,.45), 0 8px 24px rgba(150,50,95,.10);
}
#elyria-landing .lp-window-bar { display: flex; gap: 7px; align-items: center; padding: 11px 14px; background: #fdeef5; border-bottom: 1px solid var(--lp-line); }
#elyria-landing .lp-window-bar span { width: 10px; height: 10px; border-radius: 50%; background: #f2c6d9; }
#elyria-landing .lp-window img { display: block; width: 100%; height: auto; }
#elyria-landing .lp-hero-shot { position: relative; }
#elyria-landing .lp-hero-shot .lp-window-main { transform: rotate(-.6deg); }
#elyria-landing .lp-hero-shot .lp-window-float {
  position: absolute; right: -14px; bottom: -42px; width: 46%; transform: rotate(1.4deg);
}

/* Onda divisoria */
#elyria-landing .lp-wave { line-height: 0; margin-top: 50px; }
#elyria-landing .lp-wave svg { width: 100%; height: 70px; display: block; }
#elyria-landing .lp-wave path { fill: #fff; }

/* Secciones */
#elyria-landing .lp-eyebrow { text-align: center; text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 700; color: var(--lp-rose); margin: 0 0 8px; }
#elyria-landing .lp-h2 { font-family: 'Lora', Georgia, serif; font-size: 34px; text-align: center; margin: 0 auto 36px; color: var(--lp-ink); max-width: 620px; line-height: 1.2; }

/* Features */
/* Privacidad */
#elyria-landing .lp-privacy { background: #fff; padding: 8px 32px 28px; }
#elyria-landing .lp-privacy-box { max-width: 900px; margin: 0 auto; display: flex; gap: 18px; align-items: flex-start; background: var(--lp-bg); border: 1px solid var(--lp-line); border-radius: 18px; padding: 22px 26px; }
#elyria-landing .lp-privacy-ico { flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px; background: var(--lp-rose-soft); display: inline-flex; align-items: center; justify-content: center; }
#elyria-landing .lp-privacy-ico svg { width: 24px; height: 24px; fill: none; stroke: var(--lp-rose-deep); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#elyria-landing .lp-privacy-box h3 { font-family: 'Lora', Georgia, serif; font-size: 20px; margin: 0 0 6px; color: var(--lp-ink); }
#elyria-landing .lp-privacy-box p { font-size: 14.5px; line-height: 1.6; color: var(--lp-muted); margin: 0; }

#elyria-landing .lp-features { background: #fff; padding: 64px 32px 72px; }
#elyria-landing .lp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; max-width: 1080px; margin: 0 auto; }
#elyria-landing .lp-card { background: var(--lp-bg); border: 1px solid var(--lp-line); border-radius: 18px; padding: 26px 22px; transition: transform .15s, box-shadow .15s; }
#elyria-landing .lp-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px -18px rgba(150,50,95,.4); }
#elyria-landing .lp-ico { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; background: var(--lp-rose-soft); margin-bottom: 14px; }
#elyria-landing .lp-ico svg { width: 22px; height: 22px; fill: none; stroke: var(--lp-rose-deep); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#elyria-landing .lp-card h3 { font-size: 17px; margin: 0 0 7px; color: var(--lp-ink); }
#elyria-landing .lp-card p { font-size: 14px; line-height: 1.55; color: var(--lp-muted); margin: 0; }

/* Tour (texto + captura alternados) */
#elyria-landing .lp-tour { max-width: 1080px; margin: 0 auto; padding: 30px 32px; }
#elyria-landing .lp-tour-row { display: grid; grid-template-columns: 1fr 1.25fr; gap: 48px; align-items: center; padding: 40px 0; }
#elyria-landing .lp-tour-reverse .lp-tour-text { order: 2; }
#elyria-landing .lp-tour-text h3 { font-family: 'Lora', Georgia, serif; font-size: 28px; margin: 6px 0 12px; color: var(--lp-ink); }
#elyria-landing .lp-tour-text p { font-size: 16px; line-height: 1.6; color: var(--lp-muted); margin: 0; }
#elyria-landing .lp-tour-text .lp-eyebrow { text-align: left; }

/* Vision board (masonry estilo Pinterest) */
#elyria-landing .lp-visionboard { max-width: 1160px; margin: 0 auto; padding: 20px 32px 40px; text-align: center; }
#elyria-landing .lp-vb-sub { font-size: 16px; color: var(--lp-muted); max-width: 620px; margin: -22px auto 30px; line-height: 1.6; }
#elyria-landing .lp-vb-masonry { columns: 220px; column-gap: 16px; text-align: left; }
#elyria-landing .lp-vb-masonry figure {
  break-inside: avoid; margin: 0 0 16px; border-radius: 16px; overflow: hidden;
  box-shadow: 0 10px 26px -12px rgba(150,50,95,.4); background: #fbe1ec;
  transition: transform .18s, box-shadow .18s;
}
#elyria-landing .lp-vb-masonry figure:hover { transform: translateY(-4px); box-shadow: 0 18px 36px -14px rgba(150,50,95,.5); }
#elyria-landing .lp-vb-masonry img { display: block; width: 100%; height: auto; }

/* Precios */
#elyria-landing .lp-pricing { background: linear-gradient(180deg, #fff 0%, var(--lp-bg) 100%); padding: 64px 32px 72px; }
#elyria-landing .lp-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; max-width: 820px; margin: 0 auto; }
#elyria-landing .lp-plan { position: relative; background: #fff; border: 1px solid var(--lp-line); border-radius: 20px; padding: 30px 26px; }
#elyria-landing .lp-plan-featured { border: 2px solid var(--lp-rose); box-shadow: 0 24px 50px -22px rgba(215,95,146,.5); }
#elyria-landing .lp-plan-flag { position: absolute; top: -13px; left: 26px; background: var(--lp-rose); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .3px; padding: 5px 13px; border-radius: 999px; }
#elyria-landing .lp-plan-name { font-size: 14px; font-weight: 700; color: var(--lp-rose-deep); text-transform: uppercase; letter-spacing: .06em; }
#elyria-landing .lp-plan-price { font-family: 'Lora', Georgia, serif; font-size: 42px; font-weight: 600; margin: 8px 0 4px; color: var(--lp-ink); }
#elyria-landing .lp-plan-price span { font-size: 15px; color: #b79aa6; font-family: 'Inter', sans-serif; font-weight: 400; }
#elyria-landing .lp-price-old { font-size: 23px !important; color: #c85b7f !important; text-decoration: line-through; margin-right: 7px; }
#elyria-landing .lp-plan-tag { font-size: 13.5px; line-height: 1.5; color: var(--lp-muted); margin: 6px 0 4px; min-height: 40px; }
#elyria-landing .lp-plan-list { list-style: none; padding: 0; margin: 14px 0 22px; }
#elyria-landing .lp-plan-list li { font-size: 14px; color: #55414b; padding: 7px 0 7px 26px; position: relative; line-height: 1.4; }
#elyria-landing .lp-plan-list li::before { content: ""; position: absolute; left: 2px; top: 10px; width: 6px; height: 10px; border: solid var(--lp-rose); border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* CTA final + footer */
#elyria-landing .lp-final { text-align: center; padding: 76px 32px; background: #fff; }
#elyria-landing .lp-final-title { font-family: 'Lora', Georgia, serif; font-size: 34px; margin: 0 0 10px; color: var(--lp-ink); }
#elyria-landing .lp-final-sub { font-size: 16px; color: var(--lp-muted); margin: 0 0 26px; }
#elyria-landing .lp-foot { text-align: center; color: #b79aa6; font-size: 13px; padding: 26px; border-top: 1px solid var(--lp-line); background: var(--lp-bg); }
#elyria-landing .lp-foot-brand { font-family: 'Lora', Georgia, serif; color: var(--lp-rose-deep); }

@media (max-width: 900px) {
  #elyria-landing .lp-hero { grid-template-columns: 1fr; text-align: center; padding-top: 48px; }
  #elyria-landing .lp-sub { margin-left: auto; margin-right: auto; }
  #elyria-landing .lp-cta { justify-content: center; }
  #elyria-landing .lp-hero-shot { margin-top: 20px; }
  #elyria-landing .lp-hero-shot .lp-window-float { position: static; width: 78%; margin: 16px auto 0; }
  #elyria-landing .lp-tour-row, #elyria-landing .lp-tour-reverse .lp-tour-text { grid-template-columns: 1fr; order: 0; }
  #elyria-landing .lp-tour-text { text-align: center; }
  #elyria-landing .lp-tour-text .lp-eyebrow { text-align: center; }
}
@media (max-width: 620px) {
  #elyria-landing .lp-nav-links { display: none; }
  #elyria-landing .lp-title { font-size: 38px; }
  #elyria-landing .lp-plans { grid-template-columns: 1fr; }
  #elyria-landing .lp-nav { padding: 14px 18px; }
}

:root {
    --bg: #f7f3ee;
    --panel: #ffffff;
    --sheet: #ffffff;
    --text: #2b2620;
    --doc-text: #2b2620;
    --muted: #8a8174;
    --accent: #a85c32;
    --accent-soft: #f1e2d3;
    --border: #e6ddd0;
    --highlight-comment: #fde68a;
    --highlight-repeat: #fecaca;
    --highlight-filler: #c7d2fe;
    --highlight-hedge: #bbf7d0;
    --highlight-adverb: #ddd6fe;
    --highlight-adverb-hot: #fca5a5;
    --font-body: 'Lora', Georgia, serif;
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; }
  body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    transition: background .35s ease, color .35s ease;
  }

  /* ---------- THEMES ---------- */
  body.theme-claro {
    --bg: #f7f3ee; --panel: #ffffff; --sheet: #ffffff; --text: #2b2620; --doc-text: #2b2620; --muted: #8a8174;
    --accent: #a85c32; --accent-soft: #f1e2d3; --border: #e6ddd0;
  }
  body.theme-oscuro {
    --bg: #1b1b1f; --panel: #242429; --sheet: #242429; --text: #ece8e1; --doc-text: #ece8e1; --muted: #9a958c;
    --accent: #e0a96d; --accent-soft: #34302a; --border: #34343a;
  }
  body.theme-sepia {
    --bg: #ece0c8; --panel: #f5ecd8; --sheet: #f5ecd8; --text: #4a3a23; --doc-text: #4a3a23; --muted: #8a7556;
    --accent: #8a5a2b; --accent-soft: #e3d3ad; --border: #d9c79e;
  }
  body.theme-nocturno {
    --bg: #0f172a; --panel: #1a2238; --sheet: #1a2238; --text: #dbe4ff; --doc-text: #dbe4ff; --muted: #7c8db5;
    --accent: #7dd3fc; --accent-soft: #1e2c4d; --border: #2a3658;
  }
  body.theme-pastel {
    --bg: #fdf1f7; --panel: #fffafc; --sheet: #fffafc; --text: #4a2e3a; --doc-text: #4a2e3a; --muted: #b18a9c;
    --accent: #e0729c; --accent-soft: #fbe1ec; --border: #f6d4e3;
  }
  /* --- temas claros extra (estilo Ellipsus) --- */
  body.theme-lavanda {
    --bg: #f4f1fb; --panel: #ffffff; --sheet: #ffffff; --text: #33304a; --doc-text: #33304a; --muted: #8a86a3;
    --accent: #7c6bb0; --accent-soft: #e7e0f6; --border: #e3ddf0;
  }
  body.theme-menta {
    --bg: #eef6f0; --panel: #ffffff; --sheet: #ffffff; --text: #26332b; --doc-text: #26332b; --muted: #7d938a;
    --accent: #4f9d78; --accent-soft: #d9ecdf; --border: #d5e6db;
  }
  body.theme-niebla {
    --bg: #f2f4f6; --panel: #ffffff; --sheet: #ffffff; --text: #2b3440; --doc-text: #2b3440; --muted: #8894a3;
    --accent: #5b7089; --accent-soft: #e2e8ef; --border: #dde3ea;
  }
  body.theme-durazno {
    --bg: #fdf2ec; --panel: #fffaf7; --sheet: #fffaf7; --text: #433024; --doc-text: #433024; --muted: #b0917f;
    --accent: #d1743e; --accent-soft: #fbe2d3; --border: #f2ddcf;
  }
  body.theme-rosate {
    --bg: #fbf0f1; --panel: #fffafb; --sheet: #fffafb; --text: #43272d; --doc-text: #43272d; --muted: #b08a92;
    --accent: #c25b6e; --accent-soft: #f6dbe0; --border: #f1d6db;
  }
  /* --- temas oscuros extra (estilo Ellipsus) --- */
  body.theme-bosque {
    --bg: #12211a; --panel: #1b2f25; --sheet: #1b2f25; --text: #d9ecdf; --doc-text: #d9ecdf; --muted: #7d968a;
    --accent: #7fd1a3; --accent-soft: #1e3a2c; --border: #274434;
  }
  body.theme-vino {
    --bg: #1f1420; --panel: #2c1d2e; --sheet: #2c1d2e; --text: #f0dced; --doc-text: #f0dced; --muted: #a487a0;
    --accent: #e08bbf; --accent-soft: #3a2540; --border: #3d2a42;
  }
  body.theme-carbon {
    --bg: #17181c; --panel: #212329; --sheet: #212329; --text: #e3e6ec; --doc-text: #e3e6ec; --muted: #8b909c;
    --accent: #9db4d6; --accent-soft: #2a2e38; --border: #2f333d;
  }
  body.theme-cafe {
    --bg: #1e1712; --panel: #2b211a; --sheet: #2b211a; --text: #ece0d4; --doc-text: #ece0d4; --muted: #a08d7c;
    --accent: #d8a679; --accent-soft: #382a20; --border: #3a2c22;
  }

  a { color: var(--accent); }

  /* ---------- LAYOUT ---------- */
  .app {
    display: grid;
    grid-template-columns: var(--sidebar-w, 240px) 1fr 18px 340px;
    height: 100vh;
    transition: grid-template-columns .2s ease;
    position: relative;
  }
  .app.sidebar-collapsed {
    grid-template-columns: 64px 1fr 18px 340px;
  }
  /* vistas que no son "Escribir" (Estructura, Planes): usar todo el ancho */
  .app.full-main { grid-template-columns: var(--sidebar-w, 240px) 1fr 0 0; }
  .app.sidebar-collapsed.full-main { grid-template-columns: 64px 1fr 0 0; }
  .app.resizing { transition: none; user-select: none; }
  .sidebar-resizer {
    position: absolute; top: 0; left: var(--sidebar-w, 240px);
    width: 7px; height: 100%; margin-left: -3px; cursor: col-resize; z-index: 30;
  }
  .sidebar-resizer:hover { background: var(--accent); opacity: .3; }
  .app.sidebar-collapsed .sidebar-resizer, .app.focus-mode .sidebar-resizer { display: none; }
  .sidebar, .rightpanel {
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 18px;
    overflow-y: auto;
    position: relative;
  }
  .sidebar { display: flex; flex-direction: column; }
  .rightpanel { border-right: none; border-left: 1px solid var(--border); }
  .comment-gutter {
    position: relative;
    background: transparent;
    overflow: hidden;
  }

  .brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
  }
  .brand {
    font-family: var(--font-body);
    font-size: 21px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: .01em;
  }
  .collapse-btn {
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--muted);
    border-radius: 6px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 13px;
    flex-shrink: 0;
  }
  .collapse-btn:hover { color: var(--accent); border-color: var(--accent); }

  .sidebar.collapsed .label,
  .sidebar.collapsed .section-title,
  .sidebar.collapsed .premium-note,
  .sidebar.collapsed .brand,
  .sidebar.collapsed .theme-swatches,
  .sidebar.collapsed .toggle-row,
  .sidebar.collapsed .notes-panel,
  .sidebar.collapsed .reference-panel,
  .sidebar.collapsed .meta { display: none; }
  .sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }
  .sidebar.collapsed { align-items: center; }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 4px;
    width: 100%;
  }
  .nav-item:hover { background: var(--accent-soft); }
  .nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .nav-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
  .nav-item.active .nav-dot { background: var(--accent); }

  .section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin: 20px 0 8px;
  }

  .theme-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
  .swatch {
    width: 30px; height: 30px; border-radius: 50%;
    cursor: pointer; border: 2px solid transparent;
    display: flex; align-items: center; justify-content: center;
  }
  .swatch.active { border-color: var(--accent); }
  .swatch-claro { background: linear-gradient(135deg, #f7f3ee, #a85c32); }
  .swatch-oscuro { background: linear-gradient(135deg, #1b1b1f, #e0a96d); }
  .swatch-sepia { background: linear-gradient(135deg, #ece0c8, #8a5a2b); }
  .swatch-nocturno { background: linear-gradient(135deg, #0f172a, #7dd3fc); }
  .swatch-pastel { background: linear-gradient(135deg, #fdf1f7, #e0729c); }

  .toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 6px;
  }
  .switch { position: relative; width: 38px; height: 21px; flex-shrink: 0; }
  .switch input { opacity: 0; width: 0; height: 0; }
  .slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--border); border-radius: 20px; transition: .2s;
  }
  .slider:before {
    content: ""; position: absolute; width: 16px; height: 16px;
    left: 2.5px; bottom: 2.5px; background: white; border-radius: 50%; transition: .2s;
  }
  .switch input:checked + .slider { background: var(--accent); }
  .switch input:checked + .slider:before { transform: translateX(16px); }
  .premium-note { font-size: 11px; color: var(--muted); line-height: 1.4; }

  /* ---------- NOTES PANEL (sidebar) ---------- */
  .notes-panel { margin-top: 4px; }
  .note-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 8px;
    font-size: 12.5px;
    cursor: grab;
    position: relative;
  }
  .note-card.dragging { opacity: .4; }
  .note-card textarea {
    width: 100%;
    border: none;
    background: transparent;
    font-family: var(--font-ui);
    font-size: 12.5px;
    color: var(--text);
    resize: none;
    min-height: 40px;
    outline: none;
  }
  .note-card .remove-entity { position: absolute; top: 6px; right: 8px; font-size: 11px; }
  .notes-hint { font-size: 11px; color: var(--muted); line-height: 1.5; margin-bottom: 10px; }
  .drop-target-active { outline: 2px dashed var(--accent); outline-offset: -4px; }

  /* ---------- REFERENCE PANEL (sidebar, pinned entities) ---------- */
  .reference-panel { margin-top: 4px; }
  .reference-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 8px;
    font-size: 12px;
  }
  .reference-card .ref-kind { font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); font-weight: 600; }
  .reference-card .ref-name { font-family: var(--font-body); font-size: 14px; font-weight: 600; margin: 2px 0 3px; }
  .reference-card .ref-desc { color: var(--muted); font-size: 11px; line-height: 1.4; max-height: 54px; overflow: hidden; }
  .reference-empty { font-size: 11.5px; color: var(--muted); }

  .pin-btn {
    font-size: 10.5px;
    padding: 3px 9px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--muted);
    cursor: pointer;
  }
  .pin-btn.pinned { background: var(--accent); color: white; border-color: var(--accent); }

  /* ---------- CHAPTER INDEX (índice de capítulos, sidebar) ---------- */
  .toc-head {
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer; user-select: none;
  }
  .toc-head:hover { color: var(--accent); }
  .toc-caret { font-size: 13px; transition: transform .18s ease; line-height: 1; }
  .chapter-index.collapsed { display: none; }
  .toc-head.collapsed .toc-caret { transform: rotate(-90deg); }
  /* secciones colapsables del sidebar (Referencia rápida / Notas / Modo de prueba) */
  .acc-head { margin-top: 14px; }
  .acc-body.collapsed { display: none; }
  .nav-group { margin: 2px 0 2px; }
  .sidebar-foot { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--border); }
  .sidebar-foot .meta { font-size: 11.5px; display: block; margin-top: 8px; }
  .sidebar-foot .nav-foot { margin: 0; }
  .chapter-index { margin: 2px 0 4px; display: flex; flex-direction: column; gap: 1px; }
  .ci-item {
    display: flex; align-items: baseline; gap: 8px;
    padding: 5px 8px; border-radius: 6px; cursor: pointer;
    font-size: 12.5px; color: var(--text); line-height: 1.35;
    border-left: 2px solid transparent;
  }
  .ci-item:hover { background: var(--accent-soft); border-left-color: var(--accent); }
  .ci-item.active { background: var(--accent-soft); border-left-color: var(--accent); color: var(--accent); }
  .ci-title {
    flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-family: var(--font-body);
  }
  .ci-pages { font-size: 10.5px; color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
  .ci-empty { font-size: 11.5px; color: var(--muted); line-height: 1.5; padding: 0 8px; }
  .sidebar.collapsed .toc-head,
  .sidebar.collapsed .chapter-index { display: none; }

  /* ---------- MI TRABAJO (dashboard de documentos) ---------- */
  .dashboard { padding: 40px 48px 120px; }
  .dash-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
  .dash-title { font-family: var(--font-body); color: var(--accent); font-size: 30px; margin: 0 0 4px; }
  .dash-header-actions { display: flex; gap: 10px; flex-shrink: 0; }
  .dash-folder { margin-bottom: 26px; }
  .dash-folder-head {
    display: flex; align-items: center; gap: 10px;
    margin: 0 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
  }
  .dash-folder-name { font-family: var(--font-body); font-size: 17px; font-weight: 600; color: var(--text); }
  .dash-folder-count {
    font-size: 11px; color: var(--muted); background: var(--bg);
    border: 1px solid var(--border); border-radius: 10px; padding: 1px 8px;
  }
  .dash-folder-actions { margin-left: auto; display: flex; gap: 4px; }
  .dash-empty { font-size: 13px; color: var(--muted); padding: 6px 2px; }

  .doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
  .doc-card {
    position: relative;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--panel); overflow: hidden;
    transition: border-color .15s, transform .1s, box-shadow .15s;
  }
  .doc-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.10); }
  .doc-card.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
  .doc-card-body { padding: 16px 16px 14px; cursor: pointer; min-height: 74px; }
  .doc-card-title {
    font-family: var(--font-body); font-size: 17px; font-weight: 600; color: var(--text);
    line-height: 1.25; margin-bottom: 6px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .doc-untitled { color: var(--muted); font-style: italic; font-weight: 500; }
  .doc-card-meta { font-size: 11.5px; color: var(--muted); }
  .doc-card-actions {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 12px; border-top: 1px solid var(--border); background: var(--bg);
  }
  .doc-move {
    flex: 1; min-width: 0; font-family: var(--font-ui); font-size: 11.5px;
    padding: 4px 6px; border-radius: 6px; border: 1px solid var(--border);
    background: var(--panel); color: var(--text); cursor: pointer; outline: none;
  }
  .doc-act {
    border: none; background: transparent; color: var(--muted);
    cursor: pointer; font-size: 13px; line-height: 1; padding: 4px 6px; border-radius: 6px;
  }
  .doc-act:hover { background: var(--accent-soft); color: var(--accent); }

  /* ---------- ESTADO SIN DOCUMENTO ABIERTO (Escribir vacío) ---------- */
  .no-doc-msg { display: none; }
  /* cuando no hay historia abierta: ocultar editor/barra y mostrar el mensaje */
  .app.no-doc #view-write .editor-header,
  .app.no-doc #view-write .toolbar,
  .app.no-doc #editor { display: none !important; }
  .app.no-doc .float-bar { display: none !important; }
  .app.no-doc #no-doc-msg {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; margin: auto; max-width: 460px; padding: 40px 20px; gap: 4px;
  }
  .app.no-doc #no-doc-msg h2 { font-family: var(--font-body); color: var(--text); font-size: 24px; margin: 0 0 6px; }
  .app.no-doc #no-doc-msg p { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 18px; }
  .no-doc-actions { display: flex; gap: 10px; }
  /* sin documento: usar todo el ancho (esconder gutter y panel derecho) */
  .app.no-doc { grid-template-columns: var(--sidebar-w, 240px) 1fr 0 0; }
  .app.sidebar-collapsed.no-doc { grid-template-columns: 64px 1fr 0 0; }

  /* ---------- EDITOR ---------- */
  .editor-area {
    display: flex;
    flex-direction: column;
    padding: 30px 50px;
    overflow-y: auto;
    position: relative;
  }
  /* reserva un margen a la derecha para las tarjetas de comentarios */
  #view-write.has-comments { padding-right: 270px; }
  .editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
  }
  .editor-header-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
  #btn-toggle-comments.off { color: var(--muted); opacity: .6; }
  /* Botón flotante para mostrar/ocultar comentarios sin tener que subir. */
  .comments-float {
    position: fixed; left: 62px; bottom: 16px; z-index: 95;
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--panel); border: 1px solid var(--border);
    box-shadow: 0 6px 18px rgba(0,0,0,.14); cursor: pointer;
    display: flex; align-items: center; justify-content: center; color: var(--accent);
    transition: transform .12s, background .12s;
  }
  .comments-float:hover { transform: translateY(-2px); }
  .comments-float svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; }
  .app.comments-hidden .comments-float { color: var(--muted); opacity: .75; }
  .app.focus-mode .comments-float { display: none; }
  /* Conteo de palabras seleccionadas (aparece al seleccionar texto).
     Va ARRIBA de la barra flotante de formato para no taparla. */
  .sel-count {
    position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(10px);
    z-index: 96; background: var(--accent); color: #fff;
    font-family: var(--font-ui); font-size: 12.5px; font-weight: 600;
    padding: 8px 16px; border-radius: 999px; box-shadow: 0 6px 18px rgba(0,0,0,.18);
    opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; white-space: nowrap;
  }
  .sel-count.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  /* barra flotante de acciones (aparece al seleccionar/clickear una palabra) */
  .sel-tools {
    position: fixed; z-index: 60; display: none;
    gap: 4px; padding: 4px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.22);
  }
  .sel-tools.show { display: inline-flex; }
  .sel-tool-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: transparent; color: var(--text); border: none;
    border-radius: 7px; padding: 6px 10px; font-size: 12.5px; font-family: var(--font-ui);
    cursor: pointer;
  }
  .sel-tool-btn:hover { background: var(--accent-soft); color: var(--accent); }
  .sel-tool-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

  /* popover de sinónimos */
  .syn-pop {
    position: fixed; z-index: 61; display: none;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.24);
    padding: 12px; max-width: 300px;
    flex-direction: column; min-height: 0;
  }
  .syn-pop.show { display: flex; }
  .syn-pop .syn-chips { overflow-y: auto; min-height: 0; }
  .syn-pop-head { font-size: 12px; color: var(--muted); margin-bottom: 8px; font-family: var(--font-ui); }
  .syn-pop-foot { font-size: 10.5px; color: var(--muted); margin-top: 8px; }
  .syn-chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .syn-chip {
    font-family: var(--font-ui); font-size: 13px;
    background: var(--accent-soft); color: var(--accent);
    border: 1px solid var(--border); border-radius: 14px;
    padding: 4px 12px; cursor: pointer; transition: background .12s, color .12s;
  }
  .syn-chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
  .syn-empty { font-size: 12px; color: var(--muted); }

  /* panel de sugerencias */
  .sugg-card {
    border: 1px solid var(--border); border-left: 3px solid var(--accent);
    border-radius: 8px; padding: 10px 12px; margin-bottom: 10px;
    display: flex; flex-direction: column; gap: 8px;
  }
  .sugg-text { font-size: 12.5px; line-height: 1.45; color: var(--text); }
  .sugg-act {
    align-self: flex-start; font-family: var(--font-ui); font-size: 11.5px;
    background: var(--accent-soft); color: var(--accent);
    border: none; border-radius: 7px; padding: 5px 10px; cursor: pointer;
  }
  .sugg-act:hover { background: var(--accent); color: #fff; }

  /* comentarios ocultos (toggle): sin fondo Y con el color de texto del tema,
     para que la palabra no quede oscura/ilegible sobre las hojas oscuras. */
  .app.comments-hidden #editor mark.c-comment,
  .app.comments-hidden #editor mark.c-comment.focused { background: transparent; color: inherit; }
  .app.comments-hidden #view-write > .comment-card { display: none !important; }
  .story-title {
    font-family: var(--font-body);
    font-size: 27px;
    border: none;
    background: transparent;
    color: var(--text);
    width: 70%;
    outline: none;
  }
  .story-title::placeholder { color: var(--muted); }
  .meta { font-size: 12px; color: var(--muted); }

  .toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    position: sticky;
    top: 6px;
    z-index: 20;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,.05);
    transition: transform .22s ease, opacity .18s ease;
  }
  .editor-area.tb-hidden .toolbar {
    transform: translateY(-140%);
    opacity: 0;
    pointer-events: none;
  }
  .btn {
    font-family: var(--font-ui);
    font-size: 13px;
    padding: 7px 14px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
  }
  .btn:hover { background: var(--accent-soft); }
  .btn.primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
  }
  .btn.primary:hover { opacity: .88; }
  .btn:disabled { opacity: .45; cursor: not-allowed; }
  .btn.small { font-size: 12px; padding: 5px 10px; }
  .tbar-spacer { flex: 1; }
  .tbar-icon {
    width: 34px; height: 34px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--panel); color: var(--text);
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0;
  }
  .tbar-icon:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
  .tbar-icon svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

  .dropdown { position: relative; display: inline-block; }
  .dropdown-menu {
    display: none;
    position: absolute;
    top: 110%; left: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0,0,0,.12);
    min-width: 190px;
    z-index: 20;
    overflow: hidden;
  }
  .dropdown-menu.show { display: block; }
  .dropdown-item {
    padding: 9px 14px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text);
  }
  .dropdown-item:hover { background: var(--accent-soft); }

  #editor {
    flex: 1;
    font-family: var(--font-body);
    font-size: 19px;
    line-height: 1.85;
    outline: none;
    min-height: 400px;
    padding: 10px 4px 300px;
    color: var(--doc-text);
    /* cursor de escritura (línea vertical) siempre visible y con el color de acento */
    caret-color: var(--accent);
    position: relative;
  }
  #editor:empty:before {
    content: attr(data-placeholder);
    color: var(--muted);
  }
  #editor p { margin: 0 0 .5em; text-indent: 0; }
  .editor-area.auto-indent #editor p { text-indent: 2em; }
  /* el primer párrafo de cada capítulo (marcado por JS con .first-para) nunca lleva sangría */
  .editor-area.auto-indent #editor .chapter-title + p,
  .editor-area.auto-indent #editor p.first-para { text-indent: 0; }
  /* override manual por párrafo: gana siempre sobre la sangría automática */
  #editor p.indent { text-indent: 2em !important; }
  #editor p.no-indent { text-indent: 0 !important; }
  /* Título de capítulo al estilo de un libro/Word: centrado, con aire arriba,
     para que la apertura de cada capítulo se lea limpia. */
  #editor .chapter-title {
    font-family: var(--font-body);
    font-size: var(--sz-chapter, 30px);
    font-weight: 600;
    text-align: center;
    letter-spacing: .01em;
    margin: 2.2em 0 1.4em;
    page-break-before: always;
  }
  /* Subtítulo: debajo del título de capítulo, algo más chico y sin tanto aire. */
  #editor .subtitle {
    font-family: var(--font-body);
    font-size: var(--sz-subtitle, 22px);
    font-weight: 500;
    text-align: center;
    letter-spacing: .01em;
    margin: -0.6em 0 1.2em;
    line-height: 1.3;
  }
  /* Epígrafe: cita breve al inicio de un capítulo. En cursiva, alineado a la
     derecha, tamaño chico, como en los libros. */
  #editor .epigraph {
    font-family: var(--font-body);
    font-size: var(--sz-epigraph, 15px);
    font-style: italic;
    text-align: right;
    text-indent: 0 !important;
    color: var(--muted);
    margin: 0 0 1.6em auto;
    max-width: 70%;
    line-height: 1.5;
  }
  /* El primer capítulo no lleva tanto margen arriba (el margen de la hoja ya
     alcanza), así no queda un espacio raro al inicio de la primera página. */
  #editor .chapter-title:first-child { margin-top: .3em; }
  #editor .chapter-title + p { text-indent: 0; }
  /* Salto de página manual: invisible en la hoja (solo fuerza el salto). Deja una
     línea muy tenue SOLO al pasar el mouse por encima, para poder ubicarlo y
     borrarlo si hace falta. No muestra ningún cartel. */
  #editor .page-break {
    height: 0; margin: .2em 0; border: none; user-select: none;
  }
  #editor .page-break:hover {
    border-top: 1px dashed var(--border); margin: calc(.2em - 1px) 0 .2em;
  }
  /* encabezados sueltos (p. ej. de un import/pegado) acotados al tamaño del editor */
  #editor h1, #editor h2:not(.chapter-title), #editor h3, #editor h4, #editor h5, #editor h6 {
    font-family: var(--font-body); font-weight: 600; line-height: 1.3;
    margin: 1em 0 .4em;
  }
  #editor h1 { font-size: 1.5em; }
  #editor h2:not(.chapter-title) { font-size: 1.3em; }
  #editor h3 { font-size: 1.15em; }
  #editor h4, #editor h5, #editor h6 { font-size: 1em; }
  #editor mark.c-comment {
    background: var(--highlight-comment);
    color: #2b2620;
    border-radius: 2px;
    cursor: pointer;
    transition: background .15s;
  }
  #editor mark.c-comment.focused { background: #fbbf24; }
  #editor mark.c-repeat { background: var(--highlight-repeat); color: #2b2620; border-radius: 2px; }
  #editor mark.c-filler { background: var(--highlight-filler); color: #2b2620; border-radius: 2px; }
  #editor mark.c-hedge { background: var(--highlight-hedge); color: #2b2620; border-radius: 2px; }
  #editor mark.c-adverb { background: var(--highlight-adverb); color: #2b2620; border-radius: 2px; }
  #editor mark.c-adverb-hot { background: var(--highlight-adverb-hot); color: #2b2620; border-radius: 2px; font-weight: 600; }
  #editor mark.c-como { background: #cfe8ff; color: #1e3a5f; border-radius: 2px; font-weight: 600; }
  /* faltas de ortografía: subrayado ondulado rojo (como un corrector) */
  #editor mark.sp-err {
    background: transparent; color: inherit;
    text-decoration: underline wavy #e5484d; text-decoration-skip-ink: none;
    text-underline-offset: 2px; cursor: context-menu;
  }
  /* menú de click derecho del corrector */
  .sp-menu {
    position: fixed; z-index: 12000; display: none; flex-direction: column; gap: 2px;
    min-width: 180px; max-width: 240px; background: var(--panel); border: 1px solid var(--border);
    border-radius: 10px; padding: 5px; box-shadow: 0 10px 34px rgba(0,0,0,.2);
  }
  .sp-menu.show { display: flex; }
  .sp-menu .sp-sug, .sp-menu .sp-act {
    text-align: left; border: none; background: transparent; color: var(--text);
    padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; font-family: var(--font-ui);
  }
  .sp-menu .sp-sug { font-weight: 600; }
  .sp-menu .sp-sug:hover, .sp-menu .sp-act:hover { background: var(--accent-soft); color: var(--accent); }
  .sp-menu .sp-act { color: var(--muted); font-size: 12.5px; }
  .sp-menu .sp-sep { height: 1px; background: var(--border); margin: 4px 2px; }
  .sp-menu .sp-none { color: var(--muted); font-size: 12.5px; padding: 6px 10px; font-style: italic; }

  /* ---------- PORTADA / HOJA EN BLANCO (libre) ---------- */
  /* Una primera hoja para armar como quieras (texto, imágenes). Centrada
     vertical y horizontalmente por defecto; la alineación se puede cambiar. */
  #editor .title-page {
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    text-align: center; min-height: 60vh; padding: 2em 1em; margin: 0 0 1em;
    position: relative; page-break-after: always;
  }
  #editor .title-page p { width: 100%; margin: 0 0 .4em; }
  #editor .title-page .ed-figure { margin-left: auto; margin-right: auto; }
  /* pista sutil cuando está vacía (solo un párrafo sin texto) */
  #editor .title-page:has(> p:only-child:empty)::before,
  #editor .title-page:has(> p:only-child > br:only-child)::before {
    content: 'Armá tu portada: título, subtítulo, una imagen… lo que quieras.';
    color: var(--muted); font-style: italic; opacity: .7; pointer-events: none;
  }
  /* en modo Páginas, la portada ocupa (casi) toda la primera hoja */
  .editor-area.paged #editor .title-page { min-height: 78vh; }
  #editor mark.c-dialogue { background: transparent; border-bottom: 2px dotted var(--accent); }

  /* ---------- RIGHT PANEL ---------- */
  .panel-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--accent-soft);
    border-radius: 8px;
    padding: 3px;
  }
  .panel-tab {
    flex: 1;
    text-align: center;
    padding: 7px 4px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text);
  }
  .panel-tab.active { background: var(--panel); color: var(--accent); font-weight: 600; }

  .panel-view { display: none; }
  .panel-view.active { display: block; }

  /* Comentarios al margen de la hoja (estilo Google Docs) */
  .comment-card {
    position: absolute;
    width: 230px;
    z-index: 6;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    transition: top .15s ease;
  }
  .comment-card.focused { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
  .comment-card .quote {
    font-style: italic;
    color: var(--muted);
    border-left: 2px solid var(--accent);
    padding-left: 8px;
    margin-bottom: 6px;
    font-size: 12px;
  }
  .comment-card .remove { float: right; cursor: pointer; color: var(--muted); font-size: 12px; }
  .empty-hint { color: var(--muted); font-size: 13px; line-height: 1.6; }

  .stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
  }
  .issue-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .issue-actions { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
  .issue-ignore {
    border: 1px solid var(--border); background: var(--panel); color: var(--muted);
    border-radius: 6px; padding: 3px 9px; font-size: 11px; cursor: pointer; line-height: 1;
    font-family: var(--font-ui); white-space: nowrap;
  }
  .issue-ignore:hover { color: var(--accent); border-color: var(--accent); }
  .link-btn {
    background: none; border: none; color: var(--accent); cursor: pointer; padding: 0;
    font: inherit; font-size: 11px; text-decoration: underline;
  }
  .issue-nav { display: inline-flex; align-items: center; gap: 6px; }
  .issue-nav button {
    border: 1px solid var(--border); background: var(--panel); color: var(--muted);
    width: 22px; height: 22px; border-radius: 6px; cursor: pointer; line-height: 1;
    font-size: 13px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  }
  .issue-nav button:hover { color: var(--accent); border-color: var(--accent); }
  #editor mark.current { outline: 2px solid var(--accent); outline-offset: 1px; }
  .issue-card.issue-clickable { cursor: pointer; transition: border-color .12s, background .12s; }
  .issue-card.issue-clickable:hover { border-color: var(--accent); }
  .issue-card.issue-clickable.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
  .issue-hint { font-size: 11px; color: var(--muted); line-height: 1.5; margin: 0 0 10px; }
  .issue-tag { font-size: 10px; padding: 2px 7px; border-radius: 10px; color: white; }
  .tag-repeat { background: #b91c1c; }
  .tag-filler { background: #4338ca; }
  .tag-hedge { background: #15803d; }
  .tag-adverb { background: #7c3aed; }

  .page-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
    padding: 5px 8px;
    border-radius: 6px;
    margin-bottom: 4px;
    background: var(--bg);
  }
  .page-stat-row.hot { color: #b91c1c; font-weight: 600; background: #fee2e2; }
  .page-stat-row[data-hl-page] { cursor: pointer; }
  .page-stat-row[data-hl-page]:hover { outline: 1px solid var(--accent); }
  .page-stat-right { display: inline-flex; align-items: center; gap: 8px; }
  .page-stat-row.active { outline: 1px solid var(--accent); background: var(--accent-soft); }
  .page-stat-row.active { box-shadow: inset 3px 0 0 var(--accent); }

  /* ---------- PERSONAJES / LUGARES / TIMELINE ---------- */
  .subtabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
  .subtab {
    font-size: 11.5px;
    padding: 5px 10px;
    border-radius: 14px;
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--muted);
  }
  .subtab.active { background: var(--accent); color: white; border-color: var(--accent); }
  .subview { display: none; }
  .subview.active { display: block; }

  /* ----- Vocabulario ----- */
  .vsubtab, .tsubtab {
    font-size: 11.5px; padding: 5px 10px; border-radius: 14px;
    border: 1px solid var(--border); cursor: pointer; color: var(--muted);
  }
  .vsubtab.active, .tsubtab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
  .vsubview { display: none; }
  .vsubview.active { display: block; }

  .vocab-stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
  .vocab-stat {
    flex: 1 1 120px; background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px; padding: 14px 16px; text-align: center;
  }
  .vs-num { display: block; font-family: var(--font-body); font-size: 26px; color: var(--accent); line-height: 1.1; }
  .vs-lbl { display: block; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
  .vocab-meter { height: 10px; border-radius: 6px; background: var(--accent-soft); overflow: hidden; margin: 4px 0 6px; }
  .vocab-meter-fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width .4s; }
  .vocab-level { font-size: 13px; color: var(--text); font-weight: 600; margin: 0 0 10px; }

  .vocab-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px; padding: 12px 14px; margin-bottom: 10px;
  }
  .vocab-word { font-family: var(--font-body); font-size: 16px; color: var(--text); margin-bottom: 8px; }
  .vocab-count { font-size: 12px; color: var(--accent); font-family: var(--font-ui); font-weight: 600; }
  .vocab-msg { font-size: 12.5px; color: var(--muted); margin: 0 0 8px; line-height: 1.45; }
  .vocab-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .vocab-nosyn { font-size: 12px; color: var(--muted); font-style: italic; }
  .vocab-jump {
    font-size: 11.5px; padding: 4px 8px; border-radius: 12px; border: 1px dashed var(--border);
    background: transparent; color: var(--accent); cursor: pointer;
  }
  .vocab-jump:hover { background: var(--accent-soft); }
  .vocab-subhead {
    font-family: var(--font-body); font-size: 15px; color: var(--accent);
    margin: 18px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
  }
  .vocab-bank { margin-bottom: 12px; }
  .vocab-bank-cat { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
  .vocab-bank-chip {
    font-size: 12px; padding: 4px 9px; border-radius: 12px;
    background: var(--accent-soft); color: var(--text); border: 1px solid var(--border);
  }
  /* Banco de palabras (sección propia) */
  .bank-groups { display: flex; gap: 6px; margin-bottom: 10px; }
  .bank-gbtn {
    font-size: 12.5px; padding: 6px 14px; border-radius: 14px;
    border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer;
  }
  .bank-gbtn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
  .bank-gbtn .premium-pill { font-size: 8px; padding: 1px 4px; vertical-align: middle; }
  .bank-groups { flex-wrap: wrap; }
  .bank-chip-static { cursor: default; opacity: .85; }
  .bank-chip-static:hover { background: var(--accent-soft); color: var(--text); border-color: var(--border); }
  .bank-lock {
    text-align: center; padding: 26px 18px; border: 1px dashed var(--border); border-radius: 12px;
    background: var(--panel); color: var(--muted);
  }
  .bank-lock p { font-size: 13px; line-height: 1.6; margin: 0 0 14px; }
  .bank-filter { display: block; width: 100%; margin-bottom: 12px; box-sizing: border-box; }
  .bank-chip {
    font-size: 13px; padding: 5px 11px; border-radius: 12px; cursor: pointer;
    background: var(--accent-soft); color: var(--text); border: 1px solid var(--border);
    transition: background .12s, color .12s;
  }
  .bank-chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

  /* ----- Vision board ----- */
  .board-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .board-grid { columns: 220px; column-gap: 14px; }
  #view-board.board-drop { outline: 2px dashed var(--accent); outline-offset: -8px; border-radius: 12px; }
  .board-item {
    break-inside: avoid; margin: 0 0 14px; position: relative;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px; overflow: hidden;
  }
  .board-item img { display: block; width: 100%; height: auto; }
  .board-item figcaption { padding: 6px 8px; }
  .board-cap {
    width: 100%; border: none; background: transparent; color: var(--text);
    font-family: var(--font-ui); font-size: 12.5px; outline: none;
  }
  .board-cap::placeholder { color: var(--muted); }
  .board-del {
    position: absolute; top: 6px; right: 6px; width: 24px; height: 24px;
    border-radius: 50%; border: none; cursor: pointer; font-size: 16px; line-height: 1;
    background: rgba(0,0,0,.55); color: #fff; opacity: 0; transition: opacity .15s;
  }
  .board-item:hover .board-del { opacity: 1; }

  /* ----- Pizarra (lienzo libre tipo tablero de detective) ----- */
  .cork-area { flex-direction: column; padding: 0; display: none; }
  #view-corkboard { display: none; }
  .cork-toolbar {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--panel);
  }
  .cork-colors { display: inline-flex; gap: 5px; margin-left: 6px; }
  .cork-swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; }
  .cork-swatch.active { box-shadow: 0 0 0 2px var(--accent); }
  .cork-hint { font-size: 11.5px; color: var(--muted); flex: 1 1 200px; min-width: 160px; }
  .cork-scroll { flex: 1; min-height: 0; overflow: auto; position: relative; background: var(--sheet); }
  .cork-canvas {
    position: relative;
    background-image: radial-gradient(var(--border) 1.1px, transparent 1.1px);
    background-size: 24px 24px; background-position: 6px 6px;
  }
  .cork-svg { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 1; }
  .cork-hit { pointer-events: stroke; cursor: move; }
  .cork-conn.selected line:not(.cork-hit) { stroke-width: 4; }
  .cork-endpoint {
    position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; z-index: 3;
    border-radius: 50%; background: var(--panel); border: 2px solid var(--accent); cursor: grab;
  }
  .cork-el {
    position: absolute; box-sizing: border-box; z-index: 2;
  }
  .cork-el.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
  .cork-grip {
    height: 16px; cursor: move; border-radius: 8px 8px 0 0;
    background: rgba(0,0,0,.06); margin: -2px -2px 4px;
  }
  .cork-note {
    padding: 6px 8px 10px; border: 1px solid; border-radius: 4px;
    box-shadow: 2px 4px 10px rgba(0,0,0,.18); transform: rotate(-.6deg);
  }
  .cork-note .cork-grip { background: rgba(0,0,0,.08); }
  .cork-text { padding: 4px; }
  .cork-text .cork-grip { background: transparent; border-bottom: 1px dashed var(--border); border-radius: 0; opacity: .5; }
  .cork-body {
    outline: none; overflow: auto; height: calc(100% - 20px);
    font-family: var(--font-body); font-size: 15px; line-height: 1.4; color: inherit; word-break: break-word;
  }
  .cork-note .cork-body { color: #2b2620; }
  .cork-image { border-radius: 4px; overflow: hidden; box-shadow: 2px 4px 10px rgba(0,0,0,.18); background: var(--panel); }
  .cork-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .cork-circle { border: 3px solid; border-radius: 50%; background: transparent; }
  .cork-rect { border: 3px solid; border-radius: 4px; background: transparent; }
  .cork-del {
    position: absolute; top: -9px; right: -9px; width: 20px; height: 20px; border-radius: 50%;
    border: none; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; line-height: 1; cursor: pointer;
    opacity: 0; transition: opacity .12s; z-index: 4;
  }
  .cork-el:hover .cork-del { opacity: 1; }
  .cork-resize {
    position: absolute; bottom: -4px; right: -4px; width: 14px; height: 14px; cursor: nwse-resize; z-index: 4;
    background: var(--panel); border: 2px solid var(--accent); border-radius: 3px; opacity: 0; transition: opacity .12s;
  }
  .cork-el:hover .cork-resize { opacity: 1; }
  .cork-conn-del {
    position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; z-index: 5;
    border-radius: 50%; border: none; cursor: pointer; font-size: 12px; line-height: 1;
    background: rgba(0,0,0,.6); color: #fff; display: none; align-items: center; justify-content: center;
  }

  .entity-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 20px 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
    position: relative;
  }
  .entity-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }
  .entity-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
  .entity-card input.name-field {
    flex: 1;
    width: 100%;
    font-family: var(--font-body);
    font-size: 20px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--text);
    outline: none;
  }
  .entity-card input.name-field::placeholder { color: var(--muted); }
  .entity-card textarea {
    width: 100%;
    font-family: var(--font-ui);
    font-size: 13px;
    line-height: 1.55;
    border: none;
    border-radius: 8px;
    padding: 9px 11px;
    background: var(--bg);
    color: var(--text);
    resize: vertical;
    min-height: 44px;
    margin-bottom: 14px;
    outline: 1.5px solid transparent;
    transition: outline-color .15s;
  }
  .entity-card textarea:focus { outline-color: var(--accent); }
  .field-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .field-label::before {
    content: "";
    width: 4px; height: 4px; border-radius: 50%;
    background: var(--accent); flex-shrink: 0; opacity: .6;
  }
  .field-label .pin-field { margin-left: auto; }
  /* lamparita de guía + tooltip */
  .tip-btn {
    border: none; background: transparent; color: var(--muted); cursor: help;
    padding: 0; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .tip-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .tip-btn:hover { color: var(--accent); }
  .tip-pop {
    position: fixed; z-index: 200; max-width: 300px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
    padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.18);
    font-family: var(--font-ui); text-transform: none; letter-spacing: normal;
  }
  .tip-pop .tip-intro { font-size: 12.5px; color: var(--text); line-height: 1.5; margin-bottom: 8px; }
  .tip-pop .tip-qs-title { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
  .tip-pop ul { margin: 0; padding-left: 16px; }
  .tip-pop li { font-size: 12px; color: var(--text); line-height: 1.5; margin-bottom: 2px; }
  /* campos cortos: Apodo / Edad / Ocupación */
  .char-short { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
  .char-short label {
    flex: 1 1 90px; display: flex; flex-direction: column; gap: 3px;
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  }
  .char-short input {
    border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
    padding: 6px 8px; font-family: var(--font-ui); font-size: 13px; text-transform: none; letter-spacing: normal; outline: none;
  }
  .char-short input:focus { border-color: var(--accent); }
  .pin-field {
    border: none; background: transparent; color: var(--muted);
    cursor: pointer; padding: 3px; border-radius: 6px; line-height: 0; flex-shrink: 0;
  }
  .pin-field:hover { color: var(--accent); background: var(--accent-soft); }
  .pin-field.active { color: #fff; background: var(--accent); }
  .pin-field svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .tl-title-row { display: flex; align-items: center; gap: 4px; }
  .tl-title-row .tl-title { flex: 1; }
  .entity-card .remove-entity { cursor: pointer; color: var(--muted); font-size: 13px; line-height: 1; }
  .entity-card .remove-entity:hover { color: var(--accent); }

  /* categorías + tarjetas plegables + campos propios */
  .entity-group { margin-bottom: 22px; }
  .entity-group-title {
    font-family: var(--font-body); font-size: 15px; font-weight: 600; color: var(--text);
    display: flex; align-items: center; gap: 8px; margin: 4px 0 12px;
  }
  .entity-group-count {
    font-size: 11px; color: var(--muted); background: var(--bg);
    border: 1px solid var(--border); border-radius: 10px; padding: 1px 8px;
  }
  .entity-empty { font-size: 12.5px; color: var(--muted); margin: 0 0 14px 2px; }
  .entity-collapse {
    border: none; background: transparent; color: var(--muted); cursor: pointer;
    padding: 2px; border-radius: 6px; line-height: 0; flex-shrink: 0;
  }
  .entity-collapse:hover { color: var(--accent); background: var(--accent-soft); }
  .entity-collapse svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .18s ease; }
  .entity-card.collapsed .entity-collapse svg { transform: rotate(-90deg); }
  .entity-card.collapsed .entity-head { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
  .entity-card.collapsed .entity-body { display: none; }
  .entity-cat {
    font-family: var(--font-ui); font-size: 11.5px; color: var(--text);
    background: var(--bg); border: 1px solid var(--border); border-radius: 7px;
    padding: 3px 6px; cursor: pointer; outline: none;
  }
  .cf-label-row { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
  .cf-label {
    flex: 1; font-family: var(--font-ui); font-size: 10.5px; text-transform: uppercase;
    letter-spacing: .06em; color: var(--muted); font-weight: 600;
    border: none; background: transparent; outline: none; padding: 0;
  }
  .cf-label:focus { color: var(--accent); }
  .cf-remove { cursor: pointer; color: var(--muted); font-size: 12px; line-height: 1; flex-shrink: 0; }
  .cf-remove:hover { color: var(--accent); }
  .add-field { margin-top: 2px; display: inline-flex; align-items: center; gap: 6px; }
  body.premium-on .add-field .premium-pill { display: none; }

  .entity-image { margin-bottom: 14px; }
  .entity-image-wrap { position: relative; }
  .entity-image-wrap img { width: 100%; max-height: 240px; object-fit: cover; border-radius: 10px; display: block; }
  .entity-image-remove {
    position: absolute; top: 8px; right: 8px;
    background: rgba(0,0,0,.55); color: #fff; border: none;
    border-radius: 50%; width: 26px; height: 26px; cursor: pointer; font-size: 12px;
    display: flex; align-items: center; justify-content: center;
  }
  .entity-image-remove:hover { background: rgba(0,0,0,.75); }
  .entity-add-image {
    display: flex; align-items: center; gap: 8px; justify-content: center;
    border: 1px dashed var(--border); border-radius: 10px;
    padding: 14px; width: 100%;
    background: var(--bg); color: var(--muted); cursor: pointer;
    font-size: 12.5px; font-family: var(--font-ui);
  }
  .entity-add-image:hover { border-color: var(--accent); color: var(--accent); }
  .entity-add-image svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

  .reference-card { display: flex; gap: 10px; align-items: flex-start; }
  .reference-card .ref-body { flex: 1; min-width: 0; }
  .reference-card .ref-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
  .premium-field { position: relative; margin-bottom: 8px; }
  .premium-field .lock-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.03);
    backdrop-filter: blur(2px);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
    border: 1px dashed var(--accent);
  }
  body.premium-on .premium-field .lock-overlay { display: none; }
  .premium-pill { font-size: 9px; background: var(--accent); color: white; padding: 1px 6px; border-radius: 8px; }

  /* Etiqueta PREMIUM en items de navegación / subtabs / panel-tabs */
  .nav-premium { margin-left: auto; font-size: 7.5px; letter-spacing: .3px; padding: 1px 5px; opacity: .9; }
  .subtab .nav-premium, .panel-tab .nav-premium { margin-left: 5px; }
  body.premium-on .nav-premium { display: none; }

  /* Candado de funciones Premium (overlay sobre la vista bloqueada) */
  #view-board, #view-corkboard, #sub-timeline, #tab-suggest { position: relative; }
  .plan-lock {
    position: absolute; inset: 0; z-index: 30;
    display: flex; align-items: center; justify-content: center; padding: 24px;
    background: color-mix(in srgb, var(--bg) 68%, transparent);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  }
  .plan-lock-card {
    max-width: 340px; text-align: center;
    background: var(--panel); border: 1px solid var(--accent);
    border-radius: 14px; padding: 26px 24px; box-shadow: 0 10px 30px rgba(0,0,0,.18);
  }
  .plan-lock-ico { font-size: 30px; margin-bottom: 6px; }
  .plan-lock-card h3 { margin: 4px 0 8px; font-family: var(--font-body); color: var(--accent); font-size: 17px; }
  .plan-lock-card p { font-size: 13px; line-height: 1.55; color: var(--muted); margin: 0 0 16px; }
  body.premium-on .plan-lock { display: none !important; }

  .plan-includes { font-size: 12px; font-weight: 600; color: var(--accent); margin: 6px 0 2px; }

  /* Tema bloqueado en el selector (no Premium) */
  .tp-card.tp-locked { position: relative; opacity: .78; }
  .tp-card.tp-locked::after {
    content: 'PREMIUM'; position: absolute; top: 6px; right: 6px;
    font-size: 7.5px; letter-spacing: .3px; background: var(--accent); color: #fff;
    padding: 1px 5px; border-radius: 7px; font-weight: 700;
  }

  /* ---------- LÍNEA DE TIEMPO VISUAL ---------- */
  .tl-toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
  .tl-canvas-scroll {
    overflow-x: auto; overflow-y: hidden;
    border: 1px solid var(--border); border-radius: 16px;
    background: linear-gradient(var(--panel), var(--bg));
    margin-bottom: 18px; box-shadow: inset 0 1px 3px rgba(0,0,0,.04);
  }
  .tl-canvas { position: relative; height: 420px; min-width: 100%; }
  .tl-axis { position: absolute; left: 0; right: 0; top: 120px; height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-soft)); }
  .tl-marker {
    position: absolute; top: 24px; bottom: 24px; width: 0;
    border-left: 2px dashed var(--accent);
    display: flex; flex-direction: column; align-items: center;
  }
  .tl-marker-grip { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); margin-left: -9px; cursor: grab; flex-shrink: 0; box-shadow: 0 2px 6px rgba(0,0,0,.18); border: 2px solid var(--panel); }
  .tl-marker-label {
    margin-top: 6px; margin-left: -55px; width: 110px; text-align: center;
    font-family: var(--font-ui); font-size: 11px; font-weight: 600;
    border: 1px solid var(--border); border-radius: 20px; background: var(--panel);
    color: var(--text); padding: 4px 8px; outline: none; box-shadow: 0 1px 4px rgba(0,0,0,.08);
  }
  .tl-marker-label:focus { border-color: var(--accent); }
  .tl-marker-del { margin-top: 6px; margin-left: -8px; font-size: 11px; color: var(--muted); cursor: pointer; }
  .tl-marker-del:hover { color: var(--accent); }
  .tl-chip {
    font-family: var(--font-ui); font-size: 12.5px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 10px; padding: 8px 24px 8px 12px; cursor: grab;
    box-shadow: 0 2px 8px rgba(0,0,0,.1); position: relative;
    width: max-content; max-width: 250px; white-space: normal;
    word-break: break-word; line-height: 1.25;
  }
  .tl-drop-guide { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px;
    background: var(--accent); opacity: .7; pointer-events: none; z-index: 6; border-radius: 2px; }
  .tl-chip.placed { position: absolute; top: 140px; border-top: 3px solid var(--accent); }
  .tl-chip.placed::before { content: ""; position: absolute; left: 14px; top: -20px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--panel); }
  /* sucesos apilados en el mismo punto: sin el punto superior (solo el primero se conecta a la línea) */
  .tl-chip.placed.tl-stacked::before { display: none; }
  .tl-chip.placed.tl-stacked { border-top-color: var(--accent-soft); }
  .tl-chip.dragging { opacity: .4; }
  .tl-chip .tl-chip-remove { position: absolute; top: 4px; right: 7px; font-size: 11px; color: var(--muted); cursor: pointer; }
  .tl-chip .tl-chip-remove:hover { color: var(--accent); }
  .tl-tray-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
  .tl-cards { display: flex; flex-wrap: wrap; gap: 12px; min-height: 50px; }
  .tl-card {
    flex: 0 0 230px; max-width: 260px;
    background: var(--panel); border: 1px solid var(--border); border-top: 3px solid var(--accent);
    border-radius: 12px; padding: 12px 14px; position: relative; cursor: grab;
    box-shadow: 0 1px 4px rgba(0,0,0,.05); transition: box-shadow .15s;
  }
  .tl-card.dragging { opacity: .4; }
  .tl-card.flash { box-shadow: 0 0 0 2px var(--accent); }
  .tl-card .tl-order { font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-bottom: 6px; font-weight: 600; }
  .tl-card .tl-title-row { display: flex; align-items: center; gap: 4px; }
  .tl-card input.tl-title { flex: 1; min-width: 0; border: none; background: transparent; font-weight: 600; font-family: var(--font-body); font-size: 15px; color: var(--text); outline: none; }
  .tl-card .tl-body { display: none; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
  .tl-card.expanded .tl-body { display: block; }
  .tl-card textarea.tl-desc { width: 100%; border: none; background: transparent; font-size: 11.5px; line-height: 1.5; color: var(--muted); resize: vertical; min-height: 60px; outline: none; }
  .tl-card .tl-expand { margin-top: 6px; border: none; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-ui); }
  .tl-card .tl-expand:hover { color: var(--accent); }
  .tl-card .tl-expand .chev { transition: transform .15s; font-size: 9px; }
  .tl-card.expanded .tl-expand .chev { transform: rotate(180deg); }
  .tl-card .remove-entity { position: absolute; top: 8px; right: 10px; color: var(--muted); cursor: pointer; font-size: 13px; }
  .tl-card .remove-entity:hover { color: var(--accent); }
  .tl-card .tl-place { margin-top: 10px; width: 100%; border: 1px dashed var(--accent-soft); background: transparent;
    color: var(--accent); font-family: var(--font-ui); font-size: 11.5px; font-weight: 600; padding: 7px; border-radius: 8px; cursor: pointer; }
  .tl-card .tl-place:hover { background: var(--accent-soft); }
  .tl-card .tl-place.on { border-style: solid; border-color: var(--accent-soft); color: var(--muted); }
  .tl-cards.drop-target-active, .tl-canvas.drop-target-active { outline: 2px dashed var(--accent); outline-offset: -4px; }
  /* la línea de tiempo usa todo el ancho; personajes/lugares quedan más angostos */
  #sub-people, #sub-places { max-width: 820px; }

  /* ---------- PLANS ---------- */
  .plans-grid { display: flex; flex-direction: column; gap: 14px; }
  .plan-card { border: 1px solid var(--border); border-radius: 10px; padding: 16px; background: var(--bg); }
  .plan-card.premium { border-color: var(--accent); background: var(--accent-soft); }
  .plan-card h4 { margin: 0 0 4px; font-size: 15px; font-family: var(--font-body); }
  .plan-price { font-size: 22px; font-weight: bold; margin: 6px 0; }
  .plan-price span { font-size: 12px; font-weight: normal; color: var(--muted); }
  .plan-card ul { padding-left: 18px; margin: 8px 0; font-size: 12.5px; }
  .plan-card li { margin-bottom: 4px; }
  .badge-note { font-size: 11px; color: var(--muted); margin-top: 10px; line-height: 1.5; }

  .modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
  }
  .modal-overlay.show { display: flex; }
  .modal-box {
    background: var(--panel);
    color: var(--text);
    border-radius: 12px;
    padding: 20px;
    width: 380px;
    max-width: 90vw;
  }
  .modal-box h4 { font-family: var(--font-body); }
  .modal-box textarea {
    width: 100%;
    min-height: 80px;
    font-family: var(--font-ui);
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    resize: vertical;
    background: var(--bg);
    color: var(--text);
  }
  .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
  .modal-choice {
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--bg);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--text);
  }
  .modal-choice:hover { border-color: var(--accent); }
  .modal-choice small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }

  #connector-svg { position: fixed; inset: 0; pointer-events: none; z-index: 5; width: 100vw; height: 100vh; }

  /* ---------- FORMAT PANEL ---------- */
  .fmt-section { margin-bottom: 20px; }
  .fmt-section-title {
    font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
    color: var(--muted); margin: 0 0 12px;
    border-bottom: 1px solid var(--border); padding-bottom: 6px;
  }
  .fmt-field {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 10px; font-size: 13px;
  }
  .fmt-field > span { color: var(--muted); flex-shrink: 0; }
  .fmt-hint { font-size: 11.5px; color: var(--muted); line-height: 1.45; margin: -2px 0 12px; }
  .fmt-select {
    font-family: var(--font-ui); font-size: 13px;
    padding: 6px 9px; border-radius: 7px;
    border: 1px solid var(--border); background: var(--panel);
    color: var(--text); cursor: pointer; max-width: 165px;
  }
  .fmt-stepper { display: inline-flex; align-items: center; gap: 6px; }
  .fmt-stepper #fmt-size-val { min-width: 22px; text-align: center; font-size: 13px; font-weight: 600; }
  .fmt-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .fmt-btn {
    font-family: var(--font-ui); font-size: 14px;
    height: 38px; border-radius: 9px;
    border: 1px solid var(--border); background: var(--panel);
    color: var(--text); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .fmt-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
  .fmt-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
  .fmt-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .fmt-btn .lead { font-size: 17px; line-height: 1; }
  .fmt-toggle-row {
    display: flex; gap: 6px; margin-bottom: 10px;
  }
  .fmt-pill {
    flex: 1; text-align: center; padding: 8px 4px; font-size: 12.5px;
    border-radius: 8px; border: 1px solid var(--border);
    background: var(--panel); color: var(--text); cursor: pointer;
  }
  .fmt-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

  /* ---------- FLOATING FORMAT BAR ---------- */
  /* ----- Buscar y reemplazar ----- */
  .section-hint {
    font-size: 12px; color: var(--muted); margin: -4px 0 8px; line-height: 1.4;
  }

  /* ----- Sección Técnicas (guías de escritura, texto largo) ----- */
  .techniques-area { }
  .tech-article { max-width: 760px; }
  .tech-intro {
    font-size: 15px; line-height: 1.6; color: var(--text); margin: 4px 0 22px;
    opacity: .92;
  }
  .tech-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
    padding: 20px 22px; margin-bottom: 18px; box-shadow: 0 2px 10px rgba(0,0,0,.04);
  }
  .tech-card h3 {
    font-family: var(--font-body); font-size: 20px; color: var(--accent);
    margin: 0 0 12px; line-height: 1.25;
  }
  .tech-card > p { font-size: 14.5px; line-height: 1.65; margin: 0 0 10px; }
  .tech-field { font-size: 14.5px; line-height: 1.6; margin: 0 0 9px; }
  .tech-label {
    display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; color: var(--accent); background: var(--accent-soft);
    border-radius: 6px; padding: 2px 8px; margin-right: 6px; vertical-align: middle;
  }
  .tech-field.tech-avoid .tech-label { color: #b91c1c; background: #fee2e2; }
  .tech-list { margin: 4px 0 12px; padding-left: 22px; }
  .tech-list li { font-size: 14.5px; line-height: 1.6; margin-bottom: 6px; }
  .tech-eg {
    font-family: var(--font-body); font-style: italic; font-size: 14.5px; line-height: 1.6;
    color: var(--text); background: var(--bg); border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0; padding: 10px 14px; margin-top: 12px;
  }
  .tsubview { display: none; }
  .tsubview.active { display: block; }
  .find-bar {
    display: none;
    position: sticky; top: 8px; z-index: 40;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px; padding: 8px 10px; margin: 0 0 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,.10);
    flex-direction: column; gap: 6px; max-width: 520px;
  }
  .find-bar.show { display: flex; }
  .find-row { display: flex; align-items: center; gap: 6px; }
  .find-input {
    flex: 1; min-width: 0; padding: 7px 10px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg); color: var(--text);
    font-family: var(--font-ui); font-size: 13px; outline: none;
  }
  .find-input:focus { border-color: var(--accent); }
  .find-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 40px; text-align: center; }
  .find-nav, .find-close {
    width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--border);
    background: transparent; color: var(--text); cursor: pointer; font-size: 15px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .find-nav:hover, .find-close:hover { background: var(--accent-soft); color: var(--accent); }
  #editor mark.find-hit { background: rgba(224,169,109,.35); color: inherit; border-radius: 2px; }

  /* ---------- HISTORIAL DE VERSIONES ---------- */
  .history-panel {
    position: fixed; inset: 0; z-index: 10000; display: none;
    align-items: center; justify-content: center;
    background: rgba(43, 38, 32, .45); padding: 24px;
  }
  .history-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: 0 30px 70px rgba(0,0,0,.28); width: 100%; max-width: 900px;
    max-height: 86vh; padding: 22px 24px; position: relative; display: flex; flex-direction: column;
  }
  .history-x {
    position: absolute; top: 14px; right: 16px; border: none; background: none;
    font-size: 17px; color: var(--muted); cursor: pointer;
  }
  .history-x:hover { color: var(--accent); }
  .history-title { font-family: var(--font-body); font-size: 22px; color: var(--text); margin: 0 0 4px; }
  .history-sub { font-size: 13px; color: var(--muted); margin: 0 0 16px; line-height: 1.5; max-width: 620px; }
  .history-body { display: flex; gap: 18px; min-height: 0; flex: 1; }
  .history-list {
    width: 240px; flex: none; overflow-y: auto; border-right: 1px solid var(--border);
    padding-right: 12px; display: flex; flex-direction: column; gap: 6px;
  }
  .history-item {
    padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
    cursor: pointer; transition: border-color .12s, background .12s;
  }
  .history-item:hover { border-color: var(--accent); }
  .history-item.active { background: var(--accent-soft); border-color: var(--accent); }
  .history-when { font-size: 13px; font-weight: 600; color: var(--text); }
  .history-meta { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 8px; }
  .history-item.dim { opacity: .55; }
  .history-item.dim:hover, .history-item.dim.active { opacity: 1; }
  .history-chg { font-weight: 700; color: #22c55e; background: rgba(34,197,94,.16); border-radius: 999px; padding: 1px 8px; font-size: 11px; }
  .history-nochg { color: var(--muted); font-size: 11px; font-style: italic; }
  .history-preview { flex: 1; overflow-y: auto; min-width: 0; }
  .history-empty { color: var(--muted); font-size: 13.5px; padding: 20px 4px; text-align: center; }
  .history-preview-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
  }
  .history-preview-title { font-family: var(--font-body); font-size: 17px; color: var(--text); font-weight: 600; }
  .history-restore {
    padding: 9px 16px; border: none; border-radius: 999px; background: var(--accent); color: #fff;
    font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
  }
  .history-restore:hover { filter: brightness(.95); }
  .history-preview-body {
    font-family: var(--font-body); font-size: 15px; line-height: 1.7; color: var(--doc-text);
  }
  .history-preview-body p { margin: 0 0 .6em; }
  .history-preview-body .chapter-title { font-size: 20px; font-weight: 600; text-align: center; margin: 1em 0 .6em; }
  /* resumen y resaltado de cambios en la previsualización */
  .history-diff-summary {
    font-size: 12.5px; color: var(--muted); background: var(--bg); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; line-height: 1.5;
  }
  .history-diff-summary strong { color: var(--text); }
  .diff-none { color: #22c55e; font-weight: 600; }
  .diff-legend { display: inline-block; margin-left: 4px; opacity: .8; }
  /* verde translúcido: se lee bien en temas claros y oscuros, sin tocar el color del texto */
  .history-preview-body .diff-add {
    background: rgba(34,197,94,.14); border-left: 3px solid #22c55e; border-radius: 0 6px 6px 0;
    padding: 2px 10px; margin: 0 0 .5em;
  }
  @media (max-width: 720px) {
    .history-body { flex-direction: column; }
    .history-list { width: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 0 0 12px; max-height: 30vh; }
  }
  #editor mark.find-current { background: var(--accent); color: #fff; border-radius: 2px; }

  .float-bar {
    position: fixed;
    bottom: 22px; left: 50%;
    z-index: 55;
    display: flex; align-items: center; gap: 3px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 7px 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18);
    max-width: calc(100vw - 32px);
    flex-wrap: wrap; justify-content: center;
    /* oculta por defecto: aparece al seleccionar texto o al acercar el cursor abajo */
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: translateX(-50%) translateY(14px);
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
  }
  .float-bar.show { opacity: 1; visibility: visible; pointer-events: auto; transform: translateX(-50%) translateY(0); }
  /* fuera de "Escribir" (vistas full-main) nunca se muestra */
  .app.full-main .float-bar { display: none !important; }
  /* zona invisible abajo que revela la barra al pasar el cursor */
  .float-hotzone { position: fixed; left: 0; right: 0; bottom: 0; height: 70px; z-index: 54; pointer-events: none; }
  .fb-btn {
    width: 34px; height: 34px; border-radius: 9px;
    border: none; background: transparent; color: var(--text);
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    font-size: 15px; padding: 0;
  }
  .fb-btn:hover { background: var(--accent-soft); }
  .fb-btn.active { background: var(--accent); color: #fff; }
  .fb-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .fb-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
  .fb-zoom { border: none; background: transparent; color: var(--text); font-family: var(--font-ui); font-size: 13px; cursor: pointer; outline: none; }
  @media print { .float-bar { display: none !important; } }

  /* editor rich elements */
  #editor blockquote {
    margin: .7em 0; padding: .2em 0 .2em 1em;
    border-left: 3px solid var(--accent); color: var(--muted);
    font-style: italic; text-indent: 0;
  }
  #editor blockquote p { text-indent: 0; }
  #editor hr { border: none; border-top: 1px solid var(--border); margin: 1.3em 0; }
  #editor img { max-width: 100%; height: auto; border-radius: 6px; margin: .4em 0; }

  /* ---------- IMÁGENES EN EL TEXTO (estilo Word / Google Docs) ---------- */
  /* La imagen vive dentro de un <figure> atómico (no editable). El ancho se
     guarda en la figura (% del ancho del texto) y la imagen ocupa el 100% de la
     figura, así el redimensionado es predecible y se exporta bien. */
  #editor .ed-figure {
    position: relative;
    width: 60%;
    max-width: 100%;
    margin: 1em auto;
    padding: 0;
    line-height: 0;
  }
  #editor .ed-figure img { width: 100%; height: auto; margin: 0; border-radius: 6px; display: block; }
  #editor .ed-figure figcaption {
    line-height: 1.4; font-size: .82em; color: var(--muted); text-align: center;
    margin-top: .5em; font-style: italic; outline: none;
  }
  /* Modos de posición (como en Word/Docs) */
  #editor .ed-figure.fig-center { display: block; float: none; margin: 1em auto; }
  #editor .ed-figure.fig-left   { display: block; float: none; margin: 1em auto 1em 0; }
  #editor .ed-figure.fig-right  { display: block; float: none; margin: 1em 0 1em auto; }
  #editor .ed-figure.fig-wrap-left  { float: left;  margin: .2em 1.4em .8em 0; }
  #editor .ed-figure.fig-wrap-right { float: right; margin: .2em 0 .8em 1.4em; }
  #editor .ed-figure.fig-inline { display: inline-block; vertical-align: middle; margin: 0 .35em; }
  #editor .ed-figure.selected { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

  /* Mini-barra y manija de redimensionado (overlays a nivel de body). */
  .img-toolbar {
    position: fixed; z-index: 120; display: none; gap: 2px; align-items: center;
    background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
    padding: 4px; box-shadow: 0 6px 22px rgba(0,0,0,.16);
  }
  .img-toolbar.show { display: inline-flex; }
  .img-toolbar button {
    width: 30px; height: 30px; border: none; background: transparent; color: var(--text);
    border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center;
    justify-content: center; padding: 0;
  }
  .img-toolbar button:hover { background: var(--accent-soft); color: var(--accent); }
  .img-toolbar button.active { background: var(--accent-soft); color: var(--accent); }
  .img-toolbar button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .img-toolbar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 3px; }
  .img-resize-handle {
    position: fixed; z-index: 121; width: 14px; height: 14px; display: none;
    background: var(--accent); border: 2px solid #fff; border-radius: 50%;
    cursor: nwse-resize; box-shadow: 0 1px 4px rgba(0,0,0,.3);
  }
  .img-resize-handle.show { display: block; }

  /* ---------- PAGED VIEW (Disposición) ---------- */
  /* Vista Word: hojas reales apiladas. El texto fluye en #editor pero unos
     separadores (.page-spacer, insertados por JS) empujan cada bloque a la hoja
     siguiente, así ninguna línea cae en el hueco gris entre páginas. El fondo de
     las hojas se dibuja con un gradiente repetido en ::before (una sombra por hoja). */
  .editor-area.paged { align-items: center; padding: 36px 20px 140px; overflow-x: auto; }
  .editor-area.paged #editor {
    flex: none;            /* crece con el contenido */
    height: auto;
    background: transparent;
    /* ancho real de la hoja (lo fija el JS según A4/Carta). Sin max-width para que
       la paginación siempre coincida con el ancho de página; si la ventana es más
       angosta, la zona hace scroll horizontal (como el modo página de Word). */
    width: 794px;
    min-height: 1123px;
    padding: var(--page-margin, 2.5cm);   /* margen cómodo arriba, abajo y a los lados */
    position: relative;
    border-radius: 0;
  }
  .editor-area.paged #editor::before {
    content: '';
    position: absolute; inset: 0;
    z-index: 0;
    pointer-events: none;
    /* Dos gradientes repetidos (baratos, sin filtros): la capa de arriba dibuja
       una sombra suave debajo de cada hoja; la de abajo, la hoja blanca. Así se
       ven páginas apiladas sin el costo de filter: drop-shadow en docs largos. */
    background-image:
      repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent var(--page-h, 1123px),
        rgba(0,0,0,.12) var(--page-h, 1123px),
        rgba(0,0,0,0) calc(var(--page-h, 1123px) + 9px),
        transparent calc(var(--page-h, 1123px) + var(--page-gap, 28px))
      ),
      repeating-linear-gradient(
        to bottom,
        var(--sheet) 0px,
        var(--sheet) var(--page-h, 1123px),
        transparent var(--page-h, 1123px),
        transparent calc(var(--page-h, 1123px) + var(--page-gap, 28px))
      );
  }
  .editor-area.paged #editor > * { position: relative; z-index: 1; }
  .editor-area.paged #editor .page-spacer {
    z-index: 0; pointer-events: none; user-select: none;
    margin: 0; padding: 0; border: 0;
  }
  .editor-area.paged #editor .page-num {
    position: absolute; left: 0; right: 0; z-index: 1;
    text-align: center; pointer-events: none; user-select: none;
    font-family: var(--font-ui); font-size: 12px; color: var(--muted);
  }

  /* ---------- THEME PICKER ---------- */
  .theme-picker {
    background: var(--panel); color: var(--text);
    border-radius: 16px; width: 760px; max-width: 94vw;
    max-height: 86vh; display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
  }
  .tp-head {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 22px 24px 16px; border-bottom: 1px solid var(--border);
  }
  .tp-title { font-family: var(--font-body); font-size: 24px; margin: 0; color: var(--text); }
  .tp-sub { font-size: 13px; color: var(--muted); margin: 3px 0 0; }
  .tp-head-spacer { flex: 1; }
  .tp-search {
    font-family: var(--font-ui); font-size: 13px; padding: 9px 14px;
    border-radius: 20px; border: 1px solid var(--border);
    background: var(--bg); color: var(--text); width: 210px; outline: none; align-self: center;
  }
  .tp-close {
    border: none; background: transparent; color: var(--muted);
    font-size: 16px; cursor: pointer; line-height: 1; padding: 8px; align-self: center;
  }
  .tp-close:hover { color: var(--accent); }
  .tp-body { display: flex; flex: 1; overflow: hidden; }
  .tp-cats { width: 188px; flex-shrink: 0; padding: 16px 12px; overflow-y: auto; border-right: 1px solid var(--border); }
  .tp-cat {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: 8px; font-size: 13px;
    cursor: pointer; color: var(--text); margin-bottom: 2px;
  }
  .tp-cat:hover { background: var(--accent-soft); }
  .tp-cat.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .tp-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .tp-count { margin-left: auto; font-size: 11px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 1px 7px; color: var(--muted); }
  .tp-grid-wrap { flex: 1; padding: 18px 22px; overflow-y: auto; }
  .tp-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; }
  .tp-section-title.mt { margin-top: 24px; }
  .tp-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .tp-card {
    position: relative;
    border: 1px solid var(--border); border-radius: 12px; padding: 14px;
    cursor: pointer; display: flex; align-items: center; gap: 14px;
    transition: background .15s, border-color .15s, transform .1s;
  }
  .tp-card:hover { background: var(--accent-soft); border-color: var(--accent); transform: translateY(-1px); }
  .tp-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
  .tp-preview { display: flex; flex-shrink: 0; }
  .tp-preview span { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--panel); margin-left: -12px; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
  .tp-preview span:first-child { margin-left: 0; }
  .tp-name { font-size: 14px; font-weight: 500; }
  .tp-card-actions { position: absolute; top: 8px; right: 10px; display: none; gap: 8px; align-items: center; }
  .tp-card:hover .tp-card-actions { display: flex; }
  .tp-edit, .tp-del { color: var(--muted); cursor: pointer; font-size: 13px; line-height: 0; }
  .tp-edit:hover, .tp-del:hover { color: var(--accent); }
  .tp-edit svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .tp-create { border-style: dashed; justify-content: center; color: var(--muted); font-size: 14px; font-weight: 500; }
  .tp-create:hover { color: var(--accent); }
  .tp-creator { margin-top: 14px; border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: none; }
  .tp-creator.show { display: block; }
  .tp-creator .fmt-field { margin-bottom: 12px; }
  .tp-color-row input[type=color] { width: 38px; height: 30px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); cursor: pointer; padding: 2px; }
  .tp-name-input { font-family: var(--font-ui); font-size: 13px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); width: 180px; }
  .tp-creator-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

  /* premium info: solo visible al pasar el mouse por el nombre */
  .premium-section .premium-note { display: none; margin-top: 8px; }
  .premium-section:hover .premium-note,
  .premium-section:focus-within .premium-note { display: block; }
  .premium-info-trigger { border-bottom: 1px dotted var(--muted); cursor: help; }

  /* botón flotante de temas/apariencia */
  .float-config {
    position: fixed; bottom: 16px; left: 16px; z-index: 56;
    width: 38px; height: 38px; border-radius: 50%;
    border: 1px solid var(--border); background: var(--panel); color: var(--muted);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,.12); opacity: .85;
  }
  .float-config:hover { color: var(--accent); border-color: var(--accent); opacity: 1; }
  .float-config svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

  /* ---------- FOCUS MODE ---------- */
  .app.focus-mode { grid-template-columns: 1fr !important; }
  .app.focus-mode .sidebar,
  .app.focus-mode .rightpanel,
  .app.focus-mode .comment-gutter,
  .app.focus-mode .toolbar,
  .app.focus-mode #connector-svg { display: none !important; }
  .app.focus-mode .editor-area { padding: 60px 24px 160px; align-items: center; }
  .app.focus-mode .editor-header { width: 100%; max-width: 740px; }
  /* En modo enfoque SIN páginas, el editor usa el ancho cómodo de lectura.
     En modo PÁGINA no se toca el ancho (lo fija la hoja A4/Carta), si no la
     paginación se descuadra y las líneas caen sobre el borde de página. */
  .app.focus-mode .editor-area:not(.paged) #editor { width: 100%; max-width: 740px; }

  .focus-exit {
    display: none;
    position: fixed;
    top: 16px; right: 18px;
    z-index: 60;
    align-items: center; gap: 6px;
  }
  .app.focus-mode .focus-exit { display: inline-flex; }

  @media print {
    .sidebar, .rightpanel, .comment-gutter, .toolbar, .editor-header, #connector-svg,
    .img-toolbar, .img-resize-handle { display: none !important; }
    .app { display: block; height: auto; }
    .editor-area { padding: 0; overflow: visible; }
    #editor { padding: 0; min-height: 0; }
    #editor .ed-figure.selected { outline: none !important; }
    @page { size: A4; margin: 2.5cm; }
  }

  @media (max-width: 1000px) {
    .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
    .sidebar, .rightpanel { border: none; border-bottom: 1px solid var(--border); }
    .comment-gutter { display: none; }
  }