/* ── Fase 3: selector (paleta / abrir nota), búsqueda, calendario, ajustes ── */

/* Selector modal */
.selector {
  width: min(620px, calc(100vw - 32px)); max-height: none; margin: 12vh auto auto; padding: 0;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elev); color: var(--text);
  box-shadow: var(--shadow); overflow: hidden;
}
.selector[open] { animation: modal-in .14s var(--ease); }
.selector::backdrop { background: var(--scrim); }
.selector-caja { display: flex; flex-direction: column; max-height: 70vh; }
.selector-input {
  flex: none; width: 100%; height: 50px; padding: 0 18px; border: 0; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text); font-size: 16px; outline: none;
}
.selector-lista { flex: 1; overflow-y: auto; padding: 6px; }
.selector-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer;
}
.selector-item.is-active { background: var(--accent-soft); }
.selector-item > svg.icon { width: 16px; height: 16px; color: var(--muted); }
.selector-textos { flex: 1; min-width: 0; }
.selector-texto { font-size: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.selector-texto mark { background: none; color: var(--accent-text); font-weight: 700; }
.selector-detalle { font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.selector-atajo { flex: none; }
.selector-vacio { padding: 18px 14px; color: var(--muted); font-size: 13.5px; }
.selector-pie {
  flex: none; display: flex; flex-wrap: wrap; gap: 14px; padding: 8px 14px;
  border-top: 1px solid var(--border); background: var(--bg-side); font-size: 12px; color: var(--muted);
}
.selector-pie kbd { font-size: 10.5px; }

/* Barra izquierda: cabecera oculta en "Buscar" */
.side-head[hidden], .side-body[hidden] { display: none; }

/* Búsqueda */
#buscador { padding: 8px 8px 16px; }
.busq-cabecera { position: sticky; top: -8px; z-index: 1; margin: -8px -8px 6px; padding: 8px 8px 4px; background: var(--bg-side); }
.busq-campo {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg);
}
.busq-campo:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.busq-campo svg.icon { width: 15px; height: 15px; color: var(--muted); }
.busq-input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font-size: 13.5px; outline: none; }
.busq-ayuda { margin-top: 6px; font-size: 12px; color: var(--muted); }
.busq-ayuda summary { cursor: pointer; width: max-content; }
.busq-ayuda summary:hover { color: var(--text); }
.busq-ayuda dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 6px 0 2px; }
.busq-ayuda dt { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-2); }
.busq-ayuda dd { margin: 0; }
.busq-resumen { margin: 6px 4px 8px; font-size: 12px; color: var(--muted); }
.busq-nota { margin-bottom: 10px; }
.busq-nota-cab { display: flex; align-items: center; gap: 2px; }
.busq-chev { display: grid; place-items: center; width: 20px; height: 22px; padding: 0; border: 0; background: none; color: var(--muted); transition: transform .12s; }
.busq-chev svg.icon { width: 14px; height: 14px; }
.busq-nota.is-plegada .busq-chev { transform: rotate(-90deg); }
.busq-nota.is-plegada .busq-lineas { display: none; }
.busq-titulo {
  flex: 1; min-width: 0; padding: 2px 4px; border-radius: 4px; color: var(--text); font-size: 13px; font-weight: 600;
  text-decoration: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.busq-titulo:hover { background: var(--bg-hover); }
.busq-titulo mark, .busq-linea mark { background: color-mix(in srgb, #f59e0b 30%, transparent); color: inherit; border-radius: 2px; }
.busq-ruta { margin: 0 0 2px 26px; font-size: 11.5px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.busq-linea {
  margin: 3px 0 0 22px; padding: 5px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg); font-size: 12.5px; line-height: 1.45; color: var(--text-2); cursor: pointer; overflow-wrap: anywhere;
}
.busq-linea:hover { border-color: var(--border-strong); }
.busq-mas { margin: 4px 0 0 26px; font-size: 11.5px; color: var(--muted); }

/* Calendario */
.cal-cabecera { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 10px; }
.cal-titulo { font-size: 15px; font-weight: 700; text-transform: capitalize; }
.cal-nav { display: flex; align-items: center; gap: 2px; }
.cal-hoy {
  height: 24px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text-2); font-size: 12px;
}
.cal-hoy:hover { background: var(--bg-hover); }
.cal-grilla { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dia-semana { padding: 2px 0 6px; text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.cal-dia {
  position: relative; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0;
  border: 0; border-radius: 8px; background: none; color: var(--text); font-size: 13px;
}
.cal-dia:hover { background: var(--bg-hover); }
.cal-dia.es-otro-mes { color: var(--muted); opacity: .55; }
.cal-dia.es-hoy { color: var(--accent-text); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-dia.is-active { background: var(--accent); color: #fff; }
/* Puntos: uno cada 250 palabras de la nota diaria; el círculo, tareas sin marcar */
.cal-puntos { position: absolute; left: 0; right: 0; bottom: 4px; display: flex; justify-content: center; gap: 2px; height: 4px; }
.cal-punto { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.cal-punto.is-vacia { opacity: .45; }
.cal-punto.is-pendiente { background: none; box-shadow: inset 0 0 0 1px var(--accent); }
.cal-dia.is-active .cal-punto { background: #fff; }
.cal-dia.is-active .cal-punto.is-pendiente { background: none; box-shadow: inset 0 0 0 1px #fff; }
/* Tareas con fecha ese día (de cualquier nota) */
.cal-dia.tiene-tareas::before {
  content: ""; position: absolute; top: 4px; right: 5px; width: 5px; height: 5px; border-radius: 1.5px;
  background: color-mix(in srgb, #f59e0b 85%, var(--text));
}
.cal-pie { margin: 12px 4px 0; font-size: 12px; color: var(--muted); }

/* Detalle del día elegido */
.cal-detalle { margin: 14px 0 0; border-top: 1px solid var(--border); padding-top: 10px; }
.cal-detalle-cab { display: flex; align-items: center; gap: 6px; margin: 0 2px 6px 4px; min-height: 24px; }
.cal-detalle-titulo { flex: 1; font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.cal-crear {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; flex: none;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg); color: var(--text-2); font-size: 12px;
}
.cal-crear:hover { background: var(--bg-hover); color: var(--text); }
.cal-crear svg.icon { width: 13px; height: 13px; }
.cal-detalle-nota, .calv-diaria { display: flex; flex-direction: column; margin-bottom: 6px; }
.cal-detalle-meta { margin: 0 6px 0 28px; font-size: 11.5px; color: var(--muted); }
.cal-grupo { margin: 8px 0 0; }
.cal-grupo-titulo { display: flex; align-items: center; gap: 6px; margin: 0 4px 2px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.cal-tarea { display: flex; align-items: flex-start; gap: 7px; padding: 4px 6px; border-radius: var(--radius-sm); }
.cal-tarea:hover { background: var(--bg-hover); }
.cal-tarea[draggable="true"] { cursor: grab; }
.cal-tarea.is-arrastrada { opacity: .4; }
.cal-tarea .tarea-casilla { margin-top: 2px; }
.cal-tarea-cuerpo { flex: 1; min-width: 0; }
.cal-tarea-texto { font-size: 13px; line-height: 1.4; cursor: pointer; overflow-wrap: anywhere; }
.cal-tarea-nota { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-tarea.is-hecha .cal-tarea-texto { color: var(--muted); text-decoration: line-through; }
.cal-como-hoy { display: flex; flex-direction: column; }
.cal-como-hoy-cuando { margin: 4px 6px 0 6px; font-size: 11.5px; color: var(--muted); }

/* Vista de calendario (pestaña) */
.calv { position: absolute; inset: 0; display: flex; flex-direction: column; outline: none; }
.calv-barra { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.calv-nav { display: flex; align-items: center; gap: 2px; }
.calv-titulo { flex: 1; margin: 0; font-size: 17px; font-weight: 700; white-space: nowrap; }
.calv-titulo::first-letter { text-transform: uppercase; }
.calv-cuerpo { flex: 1; overflow: auto; padding: 14px 20px 24px; container-type: inline-size; }
.calv-aviso { color: var(--muted); }

.calv-mes { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-left: 1px solid var(--border); border-top: 1px solid var(--border); }
.calv-dia-semana { padding: 6px 8px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.calv-celda { display: flex; flex-direction: column; min-width: 0; padding: 4px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.calv-celda.es-otro-mes { background: var(--bg-side); }
.calv-celda.es-otro-mes .calv-num { color: var(--muted); }
.calv-cab { position: relative; display: flex; align-items: center; gap: 6px; min-height: 26px; }
.calv-cab .cal-puntos { position: static; flex: 1; justify-content: flex-start; height: auto; }
.calv-num {
  min-width: 26px; height: 26px; padding: 0 7px; border: 0; border-radius: 999px; background: none;
  color: var(--text); font-size: 13px; font-weight: 600; text-transform: capitalize; white-space: nowrap;
}
.calv-num:hover { background: var(--bg-hover); }
.calv-num.tiene-nota { color: var(--accent-text); }
.es-hoy > .calv-cab .calv-num { background: var(--accent); color: #fff; }
.calv-actividad {
  display: inline-flex; align-items: center; gap: 3px; height: 20px; padding: 0 6px; flex: none;
  border: 0; border-radius: 999px; background: var(--bg-hover); color: var(--text-2); font: 500 11px var(--font-mono);
}
.calv-actividad:hover { color: var(--accent-text); }
.calv-actividad svg.icon { width: 11px; height: 11px; }
.calv-items { display: flex; flex-direction: column; gap: 1px; flex: 1; min-height: 0; }
.calv-items .cal-tarea { padding: 2px 4px; }
.calv-items .cal-tarea-texto { font-size: 12px; }
.calv-items .tarea-casilla { width: 12px; height: 12px; margin-top: 2px; }
.calv-evento {
  display: flex; align-items: center; gap: 5px; min-width: 0; padding: 2px 4px; border-radius: 4px;
  color: var(--text); font-size: 12px; text-decoration: none;
}
.calv-evento:hover { background: var(--bg-hover); }
.calv-evento.es-todo-el-dia { background: color-mix(in srgb, var(--evento, var(--accent)) 16%, transparent); }
.calv-evento .cal-evento-color { margin-top: 0; width: 7px; height: 7px; }
.calv-evento-hora { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.calv-evento-titulo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calv-celda.is-destino, .calv-col.is-destino { outline: 2px dashed var(--accent); outline-offset: -3px; background: var(--accent-soft); }

.calv-semana { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: start; }
.calv-col { min-width: 0; min-height: 220px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius); }
.calv-col.es-hoy { border-color: var(--accent); }
.calv-col-cuerpo { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; min-height: 160px; }
.calv-col .cal-crear { align-self: flex-start; }
.calv-col .calv-evento { white-space: normal; }
@container (max-width: 900px) {
  .calv-semana { grid-template-columns: 1fr; }
  .calv-col, .calv-col-cuerpo { min-height: 0; }
}
@container (max-width: 560px) {
  .calv-items .cal-tarea-texto, .calv-evento-titulo { display: none; }
  .calv-evento-hora { display: none; }
  .calv-celda { padding: 2px; }
}

/* Año: mapa de calor */
.calv-anio { --celda: 13px; display: flex; flex-direction: column; gap: 12px; width: max-content; max-width: 100%; }
.calv-mapa { position: relative; display: grid; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.calv-mapa-mes { font-size: 11px; color: var(--muted); white-space: nowrap; text-transform: capitalize; width: var(--celda); overflow: visible; }
.calv-mapa-dia { padding-right: 6px; font-size: 10.5px; line-height: var(--celda); color: var(--muted); }
.calv-celda-mapa { display: inline-block; width: var(--celda); height: var(--celda); padding: 0; border: 0; border-radius: 3px; background: var(--bg-hover); }
.calv-celda-mapa[data-nivel="1"] { background: color-mix(in srgb, var(--accent) 28%, var(--bg-hover)); }
.calv-celda-mapa[data-nivel="2"] { background: color-mix(in srgb, var(--accent) 52%, var(--bg-hover)); }
.calv-celda-mapa[data-nivel="3"] { background: color-mix(in srgb, var(--accent) 76%, var(--bg-hover)); }
.calv-celda-mapa[data-nivel="4"] { background: var(--accent); }
button.calv-celda-mapa:hover { outline: 1.5px solid var(--text-2); outline-offset: 1px; }
.calv-celda-mapa.es-hoy { box-shadow: 0 0 0 1.5px var(--text); }
.calv-celda-mapa.es-fuera { visibility: hidden; }
.calv-mapa-pie { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; font-size: 12.5px; color: var(--muted); }
.calv-mapa-leyenda { display: inline-flex; align-items: center; gap: 3px; }
.calv-mapa-leyenda .calv-celda-mapa { width: 11px; height: 11px; }
@media (max-width: 768px) {
  .calv-barra, .calv-cuerpo { padding-left: 12px; padding-right: 12px; }
  .calv-anio { --celda: 10px; }
}

/* Campos de texto en ajustes */
.campo {
  width: 220px; max-width: 100%; height: 32px; padding: 0 10px; flex: none;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-size: 13px;
}
.campo:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#ejemplo-diario { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); }
@media (max-width: 768px) { .campo { width: 100%; } .selector { margin-top: 6vh; } }

/* ── Fase 4: adjuntos, historial, papelera, importar ── */

.setting > .btn { flex: none; white-space: nowrap; }
.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-right: 8px; }

/* Adjuntos incrustados ![[foto.png]] (vista en vivo y lectura) */
.cm-adjunto, .markdown .embed-adjunto { display: block; margin: .4em 0; white-space: normal; cursor: default; }
.adjunto-img { display: block; max-width: 100%; max-height: 70vh; height: auto; border-radius: 6px; }
.adjunto-pdf { display: block; width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-side); }
.adjunto-audio { display: block; width: 100%; max-width: 520px; }
.adjunto-video { display: block; max-width: 100%; max-height: 70vh; border-radius: 6px; background: #000; }
.adjunto-archivo {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-side);
  color: var(--text); font-size: .9em; text-decoration: none;
}
.adjunto-archivo:hover { border-color: var(--border-strong); }
.adjunto-archivo svg.icon { width: 16px; height: 16px; color: var(--muted); }

/* Modales anchos con lista + detalle */
.modal-ancho { width: min(980px, calc(100vw - 32px)); }
.modal-ancho .modal-card { padding: 0; }

/* Historial de versiones */
.hist-cuerpo { display: grid; grid-template-columns: 250px 1fr; height: min(70vh, 640px); }
.hist-lista { overflow-y: auto; padding: 6px; border-right: 1px solid var(--border); background: var(--bg-side); }
.hist-item {
  display: grid; gap: 1px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); text-align: left;
}
.hist-item:hover { background: var(--bg-hover); }
.hist-item.is-active { background: var(--accent-soft); }
.hist-cuando { font-size: 13.5px; font-weight: 600; }
.hist-meta { font-size: 12px; color: var(--muted); }
.hist-motivo { font-size: 11.5px; color: var(--accent-text); }
.hist-detalle { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.hist-barra { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.hist-leyenda { flex: 1; font-size: 12px; white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.hist-vista { flex: 1; overflow: auto; padding: 8px 0; font: 12.5px/1.55 var(--font-mono); }
.hist-linea { display: flex; padding: 0 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.hist-signo { flex: none; width: 18px; color: var(--muted); user-select: none; }
.hist-linea.is-mas { background: color-mix(in srgb, #10b981 14%, transparent); }
.hist-linea.is-menos { background: color-mix(in srgb, var(--danger) 13%, transparent); }
.hist-linea.is-mas .hist-signo { color: #10b981; }
.hist-linea.is-menos .hist-signo { color: var(--danger); }
.hist-salto { margin: 4px 0; padding: 2px 14px; color: var(--muted); font-family: var(--font-ui); font-size: 12px; background: var(--bg-side); }
.hist-texto { margin: 0; padding: 4px 16px; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
.hist-vacio { margin: 0; padding: 16px; color: var(--muted); font: 13px/1.5 var(--font-ui); }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* Papelera */
.pap-lista { max-height: min(60vh, 520px); overflow-y: auto; padding: 6px 10px; }
.pap-item { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: var(--radius-sm); }
.pap-item:hover { background: var(--bg-hover); }
.pap-item > svg.icon { flex: none; width: 17px; height: 17px; color: var(--muted); }
.pap-textos { flex: 1; min-width: 0; }
.pap-nombre { font-size: 14px; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pap-detalle { font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pap-vacia { display: grid; justify-items: center; gap: 8px; padding: 36px 12px; color: var(--muted); font-size: 13.5px; }
.pap-vacia svg.icon { width: 28px; height: 28px; opacity: .6; }
.pap-vacia p { margin: 0; }
.pap-pie { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 22px 6px; border-top: 1px solid var(--border); }

/* Importar */
.imp-cuerpo { padding: 16px 22px 0; font-size: 13.5px; }
.imp-cuerpo p { margin: 0 0 8px; }
.imp-lista {
  max-height: 150px; overflow-y: auto; margin: 0 0 10px; padding: 6px 10px 6px 26px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-side);
  font: 12px/1.6 var(--font-mono); color: var(--text-2);
}
.imp-modos { display: grid; gap: 6px; margin-bottom: 8px; }
.imp-modos label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.imp-modos input { accent-color: var(--accent); margin: 0; }
.imp-errores summary { cursor: pointer; color: var(--danger); margin-bottom: 6px; }

@media (max-width: 768px) {
  .hist-cuerpo { grid-template-columns: 1fr; grid-template-rows: 34% 1fr; height: 80vh; }
  .hist-lista { border-right: 0; border-bottom: 1px solid var(--border); }
  .hist-barra { flex-wrap: wrap; }
}

/* ── Fase 5: grafo y pestañas especiales ── */

.vista-especial-cuerpo { position: relative; flex: 1; min-height: 0; overflow: hidden; }

/* Grafo */
.grafo { position: absolute; inset: 0; display: flex; flex-direction: column; }
.grafo-lienzo { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.grafo-lienzo canvas { display: block; }
.grafo-info { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--muted); pointer-events: none; }
.grafo-vacio { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; color: var(--muted); font-size: 13px; text-align: center; pointer-events: none; }
.grafo-vacio[hidden] { display: none; }
.grafo-barra { position: absolute; top: 10px; right: 10px; z-index: 2; display: flex; gap: 2px; padding: 2px; border-radius: var(--radius); background: var(--bg-elev); box-shadow: 0 0 0 1px var(--border); }
.grafo-panel {
  position: absolute; top: 48px; right: 10px; z-index: 2; width: 270px; max-height: calc(100% - 60px); overflow-y: auto;
  padding: 4px 12px 10px; border-radius: var(--radius); background: var(--bg-elev);
  box-shadow: var(--shadow), 0 0 0 1px var(--border); font-size: 13px;
}
.grafo-panel[hidden] { display: none; }
.grafo-seccion { padding: 8px 0; border-bottom: 1px solid var(--border); }
.grafo-seccion:last-child { border-bottom: 0; }
.grafo-seccion h4 { margin: 2px 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.grafo-opcion { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; cursor: pointer; }
.grafo-opcion .switch { transform: scale(.85); transform-origin: right center; }
.grafo-rango { flex-direction: column; align-items: stretch; gap: 2px; }
.grafo-rango input { accent-color: var(--accent); width: 100%; }
.grafo-campo {
  width: 100%; min-width: 0; height: 30px; padding: 0 8px; margin-bottom: 6px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-size: 12.5px;
}
.grafo-campo:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grafo-grupo { display: flex; align-items: center; gap: 6px; }
.grafo-grupo .grafo-campo { flex: 1; margin: 0; }
.grafo-grupos { display: grid; gap: 6px; margin-bottom: 8px; }
.grafo-color { flex: none; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.grafo-color::-webkit-color-swatch-wrapper { padding: 0; }
.grafo-color::-webkit-color-swatch { border: 1px solid var(--border-strong); border-radius: 50%; }
.grafo-color::-moz-color-swatch { border: 1px solid var(--border-strong); border-radius: 50%; }

/* Grafo local (panel derecho): ocupa todo el alto del panel */
#panel-der:has(.grafo-local) { position: relative; padding: 0; overflow: hidden; }
.grafo-local .grafo-barra { position: static; margin: 8px 8px 0; align-items: center; box-shadow: none; background: none; padding: 0; }
.grafo-local .segmented button { height: 24px; font-size: 12px; padding: 0 8px; }
.grafo-espacio { flex: 1; }

/* Visor de adjuntos */
.visor-adjunto { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 20px; overflow: auto; }
.visor-adjunto .adjunto-img { max-width: 100%; max-height: calc(100% - 30px); object-fit: contain; border-radius: 4px; }
.visor-adjunto.es-pdf { padding: 0; }
.visor-adjunto .adjunto-pdf { flex: 1; width: 100%; height: auto; border: 0; border-radius: 0; }
.visor-adjunto.es-pdf .visor-pie { display: none; }
.visor-adjunto .adjunto-video { max-height: calc(100% - 30px); }
.visor-pie { font-size: 12px; }
.visor-tarjeta { display: grid; justify-items: center; gap: 8px; padding: 28px 36px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-side); text-align: center; }
.visor-tarjeta > svg.icon { width: 36px; height: 36px; color: var(--muted); }
.visor-tarjeta .btn { margin-top: 6px; }

/* ── Fase 6: tablero Kanban y vista de tareas ── */

/* El tablero usa todo el ancho, aunque el texto legible esté limitado */
body.legible .vista.en-tablero .vista-contenido, .vista.en-tablero .vista-contenido { max-width: none; padding-bottom: 32px; }
.tablero { display: flex; align-items: flex-start; gap: 12px; overflow-x: auto; padding: 8px 2px 16px; font-size: 14px; }
.kb-columna {
  flex: none; width: var(--kb-ancho, 272px); display: flex; flex-direction: column; max-height: none;
  border-radius: 10px; background: var(--bg-side); border: 1px solid var(--border);
}
.kb-columna.is-dragging { opacity: .4; }
.kb-cabecera { display: flex; align-items: center; gap: 6px; padding: 8px 6px 6px 12px; cursor: grab; }
.kb-titulo { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.kb-cuenta { font-size: 12px; color: var(--muted); }
.kb-completa { width: 15px; height: 15px; color: var(--accent); }
.kb-tarjetas { display: flex; flex-direction: column; gap: 6px; min-height: 8px; padding: 2px 8px; }
.kb-tarjetas.kb-marca { box-shadow: inset 0 2px 0 var(--accent); }
.kb-tarjeta {
  position: relative; display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px;
  border-radius: 7px; background: var(--bg-elev); border: 1px solid var(--border); cursor: grab;
  box-shadow: 0 1px 2px rgb(0 0 0 / .05);
}
.kb-tarjeta:hover { border-color: var(--border-strong); }
.kb-tarjeta.is-dragging { opacity: .35; }
.kb-tarjeta.kb-marca::before, .kb-tarjeta.kb-marca-fin::after {
  content: ""; position: absolute; left: 4px; right: 4px; height: 2px; border-radius: 2px; background: var(--accent);
}
.kb-tarjeta.kb-marca::before { top: -5px; }
.kb-tarjeta.kb-marca-fin::before { content: none; }
.kb-tarjeta.kb-marca-fin::after { bottom: -5px; }
.kb-casilla { flex: none; margin: 3px 0 0; accent-color: var(--accent); cursor: pointer; }
.kb-texto { flex: 1; min-width: 0; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.kb-texto > :first-child { margin-top: 0; }
.kb-texto > :last-child { margin-bottom: 0; }
.kb-texto p { margin: 0 0 .4em; }
.kb-tarjeta.is-hecha .kb-texto { color: var(--muted); text-decoration: line-through; }
.kb-area {
  width: 100%; min-height: 36px; padding: 8px 10px; resize: none; overflow: hidden;
  border: 1px solid var(--accent); border-radius: 7px; background: var(--bg); color: var(--text);
  font: 14px/1.45 var(--font-ui); box-shadow: 0 0 0 3px var(--accent-soft);
}
.kb-area:focus { outline: none; }
.kb-cabecera .kb-area { min-height: 30px; padding: 4px 8px; font-weight: 600; }
.kb-agregar, .kb-nueva-columna {
  display: flex; align-items: center; gap: 6px; margin: 6px 8px 8px; padding: 6px 8px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--muted); font-size: 13px; text-align: left;
}
.kb-agregar:hover, .kb-nueva-columna:hover { background: var(--bg-hover); color: var(--text); }
.kb-agregar svg.icon, .kb-nueva-columna svg.icon { width: 15px; height: 15px; }
.kb-nueva-columna { flex: none; width: 220px; margin: 0; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: 10px; }
.tablero > .kb-area { flex: none; width: 240px; }

/* Vista de tareas */
.tareas { position: absolute; inset: 0; display: flex; flex-direction: column; }
.tareas-barra { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.tareas-barra .campo { width: auto; min-width: 150px; }
.tareas-barra input.campo { flex: 1; min-width: 180px; }
.tareas-lista { flex: 1; overflow-y: auto; padding: 8px 20px 24px; }
.tareas-grupo { max-width: 860px; margin: 14px auto 0; }
.tareas-grupo-titulo {
  display: flex; align-items: center; gap: 8px; margin: 0 0 4px; padding: 2px 6px;
  font-size: 13px; font-weight: 600; color: var(--text-2); text-decoration: none; border-radius: 4px;
}
a.tareas-grupo-titulo:hover { background: var(--bg-hover); color: var(--text); }
.tarea-fila { display: flex; align-items: flex-start; gap: 10px; padding: 7px 8px; border-radius: var(--radius-sm); }
.tarea-fila:hover { background: var(--bg-hover); }
.tarea-casilla { flex: none; margin: 3px 0 0; accent-color: var(--accent); cursor: pointer; }
.tarea-texto { flex: 1; min-width: 0; font-size: 14px; line-height: 1.45; cursor: pointer; overflow-wrap: anywhere; }
.tarea-fila.is-hecha .tarea-texto { color: var(--muted); text-decoration: line-through; }
.tarea-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; flex: none; max-width: 45%; font-size: 12px; }
.tarea-fecha { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px; background: var(--bg-hover); color: var(--text-2); }
.tarea-fecha svg.icon { width: 12px; height: 12px; }
.tarea-fecha.is-hoy { background: var(--accent-soft); color: var(--accent-text); }
.tarea-fecha.is-vencida { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.tarea-prioridad { padding: 1px 7px; border-radius: 999px; font-weight: 600; }
.tarea-prioridad.p3 { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.tarea-prioridad.p2 { background: color-mix(in srgb, #f59e0b 18%, transparent); color: #b45309; }
.tarea-prioridad.p1 { background: var(--bg-hover); color: var(--muted); }
.tarea-nota { color: var(--muted); text-decoration: none; }
.tarea-nota:hover { color: var(--accent-text); }
.tareas-resumen { padding: 8px 20px; border-top: 1px solid var(--border); font-size: 12px; }
@media (max-width: 768px) {
  .tareas-barra, .tareas-lista { padding-left: 12px; padding-right: 12px; }
  .tarea-meta { max-width: 40%; }
}

/* ── Fase 7: lienzos (.canvas) ── */

.vista.en-lienzo .vista-scroll { overflow: hidden; }
body.legible .vista.en-lienzo .vista-contenido, .vista.en-lienzo .vista-contenido { max-width: none; height: 100%; padding: 0; }
.vista.en-lienzo .titulo-inline, .vista.en-lienzo .props { display: none; }
.vista.en-lienzo .vista-cuerpo { position: relative; height: 100%; }

.lienzo { position: absolute; inset: 0; overflow: hidden; outline: none; font-size: 15px; }
.lz-vista {
  position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--border-strong) 1px, transparent 1.2px);
}
.lz-vista:active { cursor: grabbing; }
.lz-mundo { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; --escala: 1; }
.lz-aristas { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.lz-nodo {
  --lz-color: var(--border-strong);
  position: absolute; display: flex; flex-direction: column; border-radius: 10px; cursor: default;
  background: var(--bg-elev); border: calc(1.5px / var(--escala)) solid var(--border-strong);
  box-shadow: 0 1px 3px rgb(0 0 0 / .08);
}
.lz-nodo.con-color { border-color: var(--lz-color); background: color-mix(in srgb, var(--lz-color) 8%, var(--bg-elev)); }
.lz-nodo.is-sel { outline: calc(2px / var(--escala)) solid var(--accent); outline-offset: calc(2px / var(--escala)); }
.lz-contenido { flex: 1; min-height: 0; overflow: auto; padding: 10px 14px; line-height: 1.5; overflow-wrap: anywhere; }
.lz-contenido > :first-child { margin-top: 0; }
.lz-contenido > :last-child { margin-bottom: 0; }
.lz-area {
  display: block; width: 100%; height: 100%; padding: 10px 14px; resize: none; border: 0; outline: none;
  background: transparent; color: var(--text); font: inherit; line-height: 1.5;
}
.lz-contenido:has(.lz-area) { overflow: hidden; padding: 0; }
.lz-archivo-titulo {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-bottom: 1px solid var(--border);
  font-size: 12.5px; font-weight: 600; color: var(--text-2); overflow: hidden; white-space: nowrap;
}
.lz-archivo-titulo svg.icon { flex: none; width: 14px; height: 14px; color: var(--muted); }
.lz-archivo-titulo span { overflow: hidden; text-overflow: ellipsis; }
.lz-nodo.is-rota .lz-contenido { color: var(--muted); font-size: 13px; }
.lz-adjunto { display: flex; align-items: center; justify-content: center; padding: 6px; }
.lz-adjunto .adjunto-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lz-adjunto .adjunto-pdf { width: 100%; height: 100%; }
.lz-enlace { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.lz-enlace svg.icon { flex: none; width: 16px; height: 16px; color: var(--muted); }
.lz-enlace a { color: var(--accent-text); overflow-wrap: anywhere; }

/* Grupos: un marco con la etiqueta encima */
.lz-group { background: color-mix(in srgb, var(--lz-color) 6%, transparent); box-shadow: none; border-style: solid; }
.lz-group:not(.con-color) { background: color-mix(in srgb, var(--text) 3%, transparent); }
.lz-grupo-etiqueta {
  position: absolute; left: 0; bottom: 100%; margin-bottom: calc(6px / var(--escala));
  padding: 2px 10px; border-radius: 6px; background: var(--bg-hover); color: var(--text-2);
  font-size: calc(14px / max(var(--escala), .6)); font-weight: 600; white-space: nowrap; cursor: pointer;
}
.lz-group.con-color .lz-grupo-etiqueta { background: color-mix(in srgb, var(--lz-color) 22%, var(--bg-elev)); }
.lz-grupo-etiqueta.is-vacia { display: none; }

/* Tirador de tamaño y conectores de flechas */
.lz-tirador {
  position: absolute; right: calc(-6px / var(--escala)); bottom: calc(-6px / var(--escala));
  width: calc(12px / var(--escala)); height: calc(12px / var(--escala));
  border-radius: 3px; background: var(--accent); cursor: nwse-resize;
}
.lz-conector {
  position: absolute; width: calc(12px / var(--escala)); height: calc(12px / var(--escala)); margin: calc(-6px / var(--escala));
  border-radius: 50%; background: var(--bg-elev); border: calc(2px / var(--escala)) solid var(--accent);
  opacity: 0; cursor: crosshair; transition: opacity .1s;
}
.lz-nodo:hover > .lz-conector, .lz-nodo.is-sel > .lz-conector { opacity: 1; }
.lz-conector[data-lado=top] { left: 50%; top: 0; }
.lz-conector[data-lado=bottom] { left: 50%; top: 100%; }
.lz-conector[data-lado=left] { left: 0; top: 50%; }
.lz-conector[data-lado=right] { left: 100%; top: 50%; }

/* Flechas */
.lz-arista { --lz-color: var(--muted); }
.lz-arista-linea { fill: none; stroke: var(--lz-color); stroke-width: calc(2px / var(--escala)); }
.lz-arista-hit { fill: none; stroke: transparent; stroke-width: calc(16px / var(--escala)); pointer-events: stroke; cursor: pointer; }
.lz-arista-punta { fill: var(--lz-color); }
.lz-arista.is-sel { --lz-color: var(--accent); }
.lz-arista-texto { fill: var(--text); font-size: 14px; paint-order: stroke; stroke: var(--bg); stroke-width: 5px; stroke-linejoin: round; }
.lz-arista-nueva { fill: none; stroke: var(--accent); stroke-width: calc(2px / var(--escala)); stroke-dasharray: 6 4; }

.lz-recuadro { position: absolute; border: 1px solid var(--accent); background: var(--accent-soft); pointer-events: none; }
.lz-recuadro[hidden] { display: none; }

.lz-barra {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 2;
  display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 10px;
  background: var(--bg-elev); box-shadow: var(--shadow), 0 0 0 1px var(--border);
}
.lz-barra-sep { width: 1px; height: 20px; margin: 0 4px; background: var(--border); }
@media (max-width: 768px) {
  /* En un celular angosto la barra no entra entera: botones más chicos y, si falta, se desplaza */
  .lz-barra { bottom: 10px; max-width: calc(100% - 16px); overflow-x: auto; scrollbar-width: none; }
  .lz-barra .icon-btn { width: 28px; flex: none; }
  .lz-barra .lz-zoom { min-width: 44px; flex: none; }
  .lz-barra-sep { margin: 0 2px; flex: none; }
}
.lz-signo { font-size: 20px; line-height: 1; }
.lz-zoom { min-width: 52px; height: 30px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-2); font: 500 12px var(--font-mono); }
.lz-zoom:hover { background: var(--bg-hover); }
.lz-error { position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 20px; background: var(--bg); color: var(--danger); text-align: center; }

/* ── Fase 8: sin conexión ── */
#status-msg { display: inline-flex; align-items: center; gap: 6px; }
#status-msg svg.icon { width: 13px; height: 13px; }
#status-msg.sin-red { color: #b45309; font-weight: 500; }
:root[data-theme="dark"] #status-msg.sin-red { color: #f59e0b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #status-msg.sin-red { color: #f59e0b; } }

/* ── Google Calendar: eventos debajo del calendario ── */
.cal-eventos { margin: 14px 0 0; border-top: 1px solid var(--border); padding-top: 10px; }
.cal-eventos-cab { display: flex; align-items: center; gap: 2px; margin: 0 2px 6px 4px; }
.cal-eventos-titulo { flex: 1; font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.cal-eventos-vacio { margin: 4px; font-size: 12.5px; color: var(--muted); }
.cal-eventos-vacio.is-error { color: var(--danger); }
.cal-evento {
  display: flex; gap: 8px; padding: 6px 6px; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-size: 13px; line-height: 1.35;
}
.cal-evento:hover { background: var(--bg-hover); }
.cal-evento-color { flex: none; width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--accent); }
.cal-evento-texto { display: flex; flex-direction: column; min-width: 0; }
.cal-evento-hora { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-evento-nombre { overflow-wrap: anywhere; }
.cal-evento-lugar { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Captura rápida ── */
.captura { width: min(560px, calc(100vw - 32px)); }
.captura .modal-card { display: flex; flex-direction: column; gap: 10px; padding: 0 0 14px; }
.captura .modal-head { padding-left: 18px; }
.captura-texto {
  width: auto; height: auto; min-height: 120px; margin: 0 16px; padding: 10px 12px; resize: vertical;
  font: 14px/1.5 var(--font-ui); flex: none;
}
.captura-archivos { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 16px; }
.captura-archivo {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 2px 2px 8px;
  border: 1px solid var(--border); border-radius: 999px; font-size: 12.5px; color: var(--text-2);
}
.captura-archivo > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.captura-archivo .icon { width: 14px; height: 14px; flex: none; }
.captura-pie { display: flex; align-items: center; gap: 8px; margin: 0 16px; flex-wrap: wrap; }
.captura-espacio { flex: 1; }
@media (max-width: 768px) {
  .captura { margin-top: 12px; }
  .captura-texto { min-height: 30vh; font-size: 16px; }   /* 16px: iOS no hace zoom al enfocar */
}

/* Kanban: barra, límites, fechas, archivo y ajustes del plugin */
.kb-barra { display: flex; gap: 6px; justify-content: flex-end; padding: 0 2px 4px; }
.kb-barra .btn svg.icon { width: 14px; height: 14px; margin-right: 4px; }
.kb-barra .btn.is-active { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.kb-cuenta.is-excedida { color: var(--danger); font-weight: 600; }
.kb-columna.is-excedida { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.tablero.sin-casillas .kb-casilla { display: none; }
.tablero.sin-cuenta .kb-cuenta { display: none; }
.kb-fecha { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; padding: 1px 6px; border-radius: 999px; font-size: 12px; color: var(--text-2); background: var(--bg-hover); text-decoration: none; }
.kb-fecha svg.icon { width: 12px; height: 12px; }
.kb-fecha.is-hoy { color: var(--accent-text); background: var(--accent-soft); }
.kb-fecha.is-vencida { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.kb-tarjeta.is-hecha .kb-fecha { opacity: .7; }
.kb-archivo { background: color-mix(in srgb, var(--bg-side) 70%, var(--bg)); border-style: dashed; }
.kb-archivo .kb-cabecera { cursor: default; }
.kb-archivo .kb-cabecera svg.icon { width: 15px; height: 15px; color: var(--muted); }
.kb-tarjeta.is-archivada { flex-direction: column; align-items: stretch; cursor: default; }
.kb-archivo-acciones { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.kb-vacio { margin: 4px 4px 10px; font-size: 13px; }
.kb-ajustes h2 { margin-bottom: 12px; }
.kb-ajuste { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 14px; }
.kb-ajuste input[type=number] { width: 80px; }

/* Grafo: buscar un nodo (resalta sin filtrar) */
.grafo-barra { align-items: center; }
.grafo-buscar { display: flex; align-items: center; gap: 4px; height: 26px; padding: 0 6px; margin-right: 2px; border-radius: var(--radius-sm); background: var(--bg); }
.grafo-buscar:focus-within { box-shadow: 0 0 0 1.5px var(--accent); }
.grafo-buscar svg.icon { width: 14px; height: 14px; color: var(--muted); flex: none; }
.grafo-buscar input { width: 150px; border: 0; background: none; color: var(--text); font-size: 12.5px; outline: none; }
.grafo-buscar-cuenta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
